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 Vec4d.h
7
/** @file Vec4d.h
8
 * @brief 4D double vector class.
8
 * @brief 4D double vector class.
9
 */
9
 */
10
 
10
 
11
#ifndef __CGLA_VEC4D_H__
11
#ifndef __CGLA_VEC4D_H__
12
#define __CGLA_VEC4D_H__
12
#define __CGLA_VEC4D_H__
13
 
13
 
14
#include "Vec3d.h"
14
#include "Vec3d.h"
15
#include "ArithVec4Float.h"
15
#include "ArithVec4Float.h"
16
 
16
 
17
namespace CGLA {
17
namespace CGLA {
18
 
18
 
19
	/** \brief A four dimensional floating point vector. 
19
	/** \brief A four dimensional floating point vector. 
20
 
20
 
21
			This class is also used (via typedef) for
21
			This class is also used (via typedef) for
22
			homogeneous vectors.
22
			homogeneous vectors.
23
	*/
23
	*/
24
 
24
 
25
	class Vec4d: public ArithVec4Float<double,Vec4d>
25
	class Vec4d: public ArithVec4Float<double,Vec4d>
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
		Vec4d(): ArithVec4Float<double,Vec4d>(0.0,0.0,0.0,0.0) {}
30
		Vec4d(): ArithVec4Float<double,Vec4d>(0.0,0.0,0.0,0.0) {}
31
 
31
 
32
		/// Construct a (0,0,0,0) homogenous Vector
32
		/// Construct a (0,0,0,0) homogenous Vector
33
		explicit Vec4d(double _a): ArithVec4Float<double,Vec4d>(_a,_a,_a,_a) {}
33
		explicit Vec4d(double _a): ArithVec4Float<double,Vec4d>(_a,_a,_a,_a) {}
34
 
34
 
35
		/// Construct a 4D vector
35
		/// Construct a 4D vector
36
		Vec4d(double _a, double _b, double _c, double _d): 
36
		Vec4d(double _a, double _b, double _c, double _d): 
37
			ArithVec4Float<double,Vec4d>(_a,_b,_c,_d) {}
37
			ArithVec4Float<double,Vec4d>(_a,_b,_c,_d) {}
38
 
38
 
39
		/// Construct a homogenous vector (a,b,c,1)
39
		/// Construct a homogenous vector (a,b,c,1)
40
		Vec4d(double _a, double _b, double _c): 
40
		Vec4d(double _a, double _b, double _c): 
41
			ArithVec4Float<double,Vec4d>(_a,_b,_c,1.0) {}
41
			ArithVec4Float<double,Vec4d>(_a,_b,_c,1.0) {}
42
 
42
 
43
		/// Construct a homogenous vector from a non-homogenous.
43
		/// Construct a homogenous vector from a non-homogenous.
44
		explicit Vec4d(const Vec3d& v): 
44
		explicit Vec4d(const Vec3d& v): 
45
			ArithVec4Float<double,Vec4d>(v[0],v[1],v[2],1.0) {}
45
			ArithVec4Float<double,Vec4d>(v[0],v[1],v[2],1.0) {}
46
 
46
 
47
		/// Construct a homogenous vector from a non-homogenous.
47
		/// Construct a homogenous vector from a non-homogenous.
48
		explicit Vec4d(const Vec3d& v,double _d): 
48
		explicit Vec4d(const Vec3d& v,double _d): 
49
			ArithVec4Float<double,Vec4d>(v[0],v[1],v[2],_d) {}
49
			ArithVec4Float<double,Vec4d>(v[0],v[1],v[2],_d) {}
50
 
50
 
51
		operator Vec3d() const
51
		operator Vec3d() const
52
		{
52
		{
53
			double k = 1.0/(*this)[3];
53
			double k = 1.0/(*this)[3];
54
			return Vec3d((*this)[0]*k,(*this)[1]*k,(*this)[2]*k);
54
			return Vec3d((*this)[0]*k,(*this)[1]*k,(*this)[2]*k);
55
		}
55
		}
56
	};
56
	};
57
}
57
}
58
#endif
58
#endif
59
 
59
 
60
 
60