Subversion Repositories gelsvn

Rev

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

Rev 501 Rev 595
-
 
1
/* ----------------------------------------------------------------------- *
-
 
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
-
 
3
 * Copyright (C) the authors and DTU Informatics
-
 
4
 * For license and list of authors, see ../../doc/intro.pdf
-
 
5
 * ----------------------------------------------------------------------- */
-
 
6
 
-
 
7
/** @file Vec4f.h
-
 
8
 * @brief 4D float vector class.
-
 
9
 */
-
 
10
 
1
#ifndef __CGLA_VEC4F_H__
11
#ifndef __CGLA_VEC4F_H__
2
#define __CGLA_VEC4F_H__
12
#define __CGLA_VEC4F_H__
3
 
13
 
4
#include "Vec3f.h"
14
#include "Vec3f.h"
5
#include "ArithVec4Float.h"
15
#include "ArithVec4Float.h"
6
 
16
 
7
namespace CGLA {
17
namespace CGLA {
8
 
18
 
9
	/** \brief A four dimensional floating point vector. 
19
	/** \brief A four dimensional floating point vector. 
10
 
20
 
11
			This class is also used (via typedef) for
21
			This class is also used (via typedef) for
12
			homogeneous vectors.
22
			homogeneous vectors.
13
	*/
23
	*/
14
 
24
 
15
	class Vec4f: public ArithVec4Float<float,Vec4f>
25
	class Vec4f: public ArithVec4Float<float,Vec4f>
16
	{
26
	{
17
	public:
27
	public:
18
  
28
  
19
		/// Construct a (0,0,0,0) homogenous Vector
29
		/// Construct a (0,0,0,0) homogenous Vector
20
		Vec4f(): ArithVec4Float<float,Vec4f>(0.0f,0.0f,0.0f,0.0f) {}
30
		Vec4f(): ArithVec4Float<float,Vec4f>(0.0f,0.0f,0.0f,0.0f) {}
21
 
31
 
22
		/// Construct a (0,0,0,0) homogenous Vector
32
		/// Construct a (0,0,0,0) homogenous Vector
23
		explicit Vec4f(float _a): ArithVec4Float<float,Vec4f>(_a,_a,_a,_a) {}
33
		explicit Vec4f(float _a): ArithVec4Float<float,Vec4f>(_a,_a,_a,_a) {}
24
 
34
 
25
		/// Construct a 4D vector
35
		/// Construct a 4D vector
26
		Vec4f(float _a, float _b, float _c, float _d): 
36
		Vec4f(float _a, float _b, float _c, float _d): 
27
			ArithVec4Float<float,Vec4f>(_a,_b,_c,_d) {}
37
			ArithVec4Float<float,Vec4f>(_a,_b,_c,_d) {}
28
 
38
 
29
		/// Construct a homogenous vector (a,b,c,1)
39
		/// Construct a homogenous vector (a,b,c,1)
30
		Vec4f(float _a, float _b, float _c): 
40
		Vec4f(float _a, float _b, float _c): 
31
			ArithVec4Float<float,Vec4f>(_a,_b,_c,1.0f) {}
41
			ArithVec4Float<float,Vec4f>(_a,_b,_c,1.0f) {}
32
 
42
 
33
		/// Construct a homogenous vector from a non-homogenous.
43
		/// Construct a homogenous vector from a non-homogenous.
34
		explicit Vec4f(const Vec3f& v): 
44
		explicit Vec4f(const Vec3f& v): 
35
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],1.0f) {}
45
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],1.0f) {}
36
 
46
 
37
		/// Construct a homogenous vector from a non-homogenous.
47
		/// Construct a homogenous vector from a non-homogenous.
38
		explicit Vec4f(const Vec3f& v,float _d): 
48
		explicit Vec4f(const Vec3f& v,float _d): 
39
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],_d) {}
49
			ArithVec4Float<float,Vec4f>(v[0],v[1],v[2],_d) {}
40
 
50
 
41
		operator Vec3f() const
51
		operator Vec3f() const
42
		{
52
		{
43
			float k = 1.0f/(*this)[3];
53
			float k = 1.0f/(*this)[3];
44
			return Vec3f((*this)[0]*k,(*this)[1]*k,(*this)[2]*k);
54
			return Vec3f((*this)[0]*k,(*this)[1]*k,(*this)[2]*k);
45
		}
55
		}
46
	};
56
	};
47
}
57
}
48
#endif
58
#endif
49
 
59
 
50
 
60