Subversion Repositories gelsvn

Rev

Rev 2 | Rev 89 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
1
#ifndef __CGLA_ARITHVEC4FLOAT_H__
1
#ifndef __CGLA_ARITHVEC4FLOAT_H__
2
#define __CGLA_ARITHVEC4FLOAT_H__
2
#define __CGLA_ARITHVEC4FLOAT_H__
3
 
3
 
4
#include "ArithVecFloat.h"
4
#include "ArithVecFloat.h"
5
 
5
 
6
namespace CGLA {
6
namespace CGLA {
7
 
7
 
8
	/** A four dimensional floating point vector. 
8
	/** A four dimensional floating point vector. 
9
			This class is also used (via typedef) for
9
			This class is also used (via typedef) for
10
			homogeneous vectors.
10
			homogeneous vectors.
11
	*/
11
	*/
12
 
12
 
13
	template<class T, class V>
13
	template<class T, class V>
14
	class ArithVec4Float: public ArithVecFloat<T,V,4>
14
	class ArithVec4Float: public ArithVecFloat<T,V,4>
15
	{
15
	{
16
	public:
16
	public:
17
  
17
  
18
		/// Construct a (0,0,0,0) homogenous Vector
18
		/// Construct a (0,0,0,0) homogenous Vector
19
		ArithVec4Float() {}
19
		ArithVec4Float() {}
20
 
20
 
21
		/// Construct a 4D vector
21
		/// Construct a 4D vector
22
		ArithVec4Float(T a, T b, T c, T d): 
22
		ArithVec4Float(T a, T b, T c, T d): 
23
			ArithVecFloat<T,V,4>(a,b,c,d) {}
23
			ArithVecFloat<T,V,4>(a,b,c,d) {}
24
 
24
 
25
		/// Divide all coordinates by the fourth coordinate
25
		/// Divide all coordinates by the fourth coordinate
26
		void de_homogenize()
26
		void de_homogenize()
27
		{
27
		{
28
			float k = 1.0f/(*this)[3];
28
			float k = 1.0/(*this)[3];
29
			(*this)[0] = (*this)[0]*k;
29
			(*this)[0] = (*this)[0]*k;
30
			(*this)[1] = (*this)[1]*k;
30
			(*this)[1] = (*this)[1]*k;
31
			(*this)[2] = (*this)[2]*k;
31
			(*this)[2] = (*this)[2]*k;
32
			(*this)[3] = 1.0;
32
			(*this)[3] = 1.0;
33
		}
33
		}
34
 
34
 
35
	};
35
	};
36
}
36
}
37
#endif
37
#endif
38
 
38
 
39
 
39