Subversion Repositories gelsvn

Rev

Rev 89 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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