Subversion Repositories gelsvn

Rev

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