Subversion Repositories gelsvn

Rev

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

Rev 595 Rev 630
1
/* ----------------------------------------------------------------------- *
1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
5
 * ----------------------------------------------------------------------- */
6
 
6
 
7
/** @file ArithVec4Float.h
7
/** @file ArithVec4Float.h
8
 * @brief Abstract 4D floating point vector class
8
 * @brief Abstract 4D floating point vector class
9
 */
9
 */
10
 
10
 
11
#ifndef __CGLA_ARITHVEC4FLOAT_H__
11
#ifndef __CGLA_ARITHVEC4FLOAT_H__
12
#define __CGLA_ARITHVEC4FLOAT_H__
12
#define __CGLA_ARITHVEC4FLOAT_H__
13
 
13
 
14
#include "ArithVecFloat.h"
14
#include "ArithVecFloat.h"
15
 
15
 
16
namespace CGLA {
16
namespace CGLA {
17
 
17
 
18
	/** \brief A four dimensional floating point vector template. 
18
	/** \brief A four dimensional floating point vector template. 
19
 
19
 
20
			This class is also used (via typedef) for
20
			This class is also used (via typedef) for
21
			homogeneous vectors.
21
			homogeneous vectors.
22
	*/
22
	*/
23
 
23
 
24
	template<class T, class V>
24
	template<class T, class V>
25
	class ArithVec4Float: public ArithVecFloat<T,V,4>
25
	class ArithVec4Float: public ArithVecFloat<T,V,4>
26
	{
26
	{
27
	public:
27
	public:
28
  
28
  
29
		/// Construct a (0,0,0,0) homogenous Vector
29
		/// Construct a (0,0,0,0) homogenous Vector
30
		ArithVec4Float() {}
30
		ArithVec4Float() {}
31
 
31
 
32
		/// Construct a 4D vector
32
		/// Construct a 4D vector
33
		ArithVec4Float(T a, T b, T c, T d): 
33
		ArithVec4Float(T a, T b, T c, T d): 
34
			ArithVecFloat<T,V,4>(a,b,c,d) {}
34
			ArithVecFloat<T,V,4>(a,b,c,d) {}
35
 
35
 
36
		/// Divide all coordinates by the fourth coordinate
36
		/// Divide all coordinates by the fourth coordinate
37
		void de_homogenize()
37
		void de_homogenize()
38
		{
38
		{
39
			float k = 1.0/(*this)[3];
39
			float k = 1.0/(*this)[3];
40
			(*this)[0] = (*this)[0]*k;
40
			(*this)[0] = (*this)[0]*k;
41
			(*this)[1] = (*this)[1]*k;
41
			(*this)[1] = (*this)[1]*k;
42
			(*this)[2] = (*this)[2]*k;
42
			(*this)[2] = (*this)[2]*k;
43
			(*this)[3] = 1.0;
43
			(*this)[3] = 1.0;
44
		}
44
		}
45
 
45
 
46
	};
46
	};
47
}
47
}
48
#endif
48
#endif
49
 
49
 
50
 
50