Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

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