Subversion Repositories gelsvn

Rev

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

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