Subversion Repositories gelsvn

Rev

Rev 67 | Details | Compare with Previous | Last modification | View Log | RSS feed

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