Subversion Repositories gelsvn

Rev

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

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