Subversion Repositories gelsvn

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
#ifndef __CGLA_VEC4F_H__
2
#define __CGLA_VEC4F_H__
3
 
4
#include "Vec3f.h"
5
#include "ArithVec4Float.h"
6
 
7
namespace CGLA {
8
 
89 jab 9
	/** \brief A four dimensional floating point vector. 
10
 
2 bj 11
			This class is also used (via typedef) for
12
			homogeneous vectors.
13
	*/
14
 
15
	class Vec4f: public ArithVec4Float<float,Vec4f>
16
	{
17
	public:
18
 
19
		/// Construct a (0,0,0,0) homogenous Vector
20
		Vec4f(): ArithVec4Float<float,Vec4f>(0,0,0,0.0) {}
21
 
22
		/// Construct a (0,0,0,0) homogenous Vector
23
		explicit Vec4f(float _a): ArithVec4Float<float,Vec4f>(_a,_a,_a,_a) {}
24
 
25
		/// Construct a 4D vector
26
		Vec4f(float _a, float _b, float _c, float _d): 
27
			ArithVec4Float<float,Vec4f>(_a,_b,_c,_d) {}
28
 
29
		/// Construct a homogenous vector (a,b,c,1)
30
		Vec4f(float _a, float _b, float _c): 
31
			ArithVec4Float<float,Vec4f>(_a,_b,_c,1.0) {}
32
 
33
		/// Construct a homogenous vector from a non-homogenous.
34
		explicit Vec4f(const Vec3f& v): 
35
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],1.0) {}
36
 
37
		/// Construct a homogenous vector from a non-homogenous.
38
		explicit Vec4f(const Vec3f& v,float _d): 
39
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],_d) {}
40
 
41
		operator Vec3f() const
42
		{
43
			float k = 1.0f/(*this)[3];
44
			return Vec3f((*this)[0]*k,(*this)[1]*k,(*this)[2]*k);
45
		}
46
	};
47
}
48
#endif
49