Subversion Repositories gelsvn

Rev

Rev 2 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 569
1
#ifndef __CGLA__ARITHVEC3FLOAT_H__
1
#ifndef __CGLA__ARITHVEC3FLOAT_H__
2
#define __CGLA__ARITHVEC3FLOAT_H__
2
#define __CGLA__ARITHVEC3FLOAT_H__
3
 
3
 
4
#include "ArithVecFloat.h"
4
#include "ArithVecFloat.h"
5
 
5
 
6
namespace CGLA {
6
namespace CGLA {
7
 
7
 
8
	template<class T, class V>
8
	template<class T, class V>
9
	class ArithVec3Float: public ArithVecFloat<T,V,3>
9
	class ArithVec3Float: public ArithVecFloat<T,V,3>
10
	{
10
	{
11
	public:
11
	public:
12
 
12
 
13
		/// Construct a 3D float vector.
13
		/// Construct a 3D float vector.
14
		ArithVec3Float(T a, T b, T c): ArithVecFloat<T,V,3>(a,b,c) {}
14
		ArithVec3Float(T a, T b, T c): ArithVecFloat<T,V,3>(a,b,c) {}
15
 
15
 
16
		/// Construct a 3D float vector.
16
		/// Construct a 3D float vector.
17
		ArithVec3Float() {}
17
		ArithVec3Float() {}
18
 
18
 
19
		/** Get the vector in spherical coordinates.
19
		/** Get the vector in spherical coordinates.
20
				The first argument (theta) is inclination from the vertical axis.
20
				The first argument (theta) is inclination from the vertical axis.
21
				The second argument (phi) is the angle of rotation about the vertical 
21
				The second argument (phi) is the angle of rotation about the vertical 
22
				axis. The third argument (r) is the length of the vector. */
22
				axis. The third argument (r) is the length of the vector. */
23
		void get_spherical( T&, T&, T& ) const;
23
		void get_spherical( T&, T&, T& ) const;
24
 
24
 
25
		/** Assign the vector in spherical coordinates.
25
		/** Assign the vector in spherical coordinates.
26
				The first argument (theta) is inclination from the vertical axis.
26
				The first argument (theta) is inclination from the vertical axis.
27
				The second argument (phi) is the angle of rotation about the vertical 
27
				The second argument (phi) is the angle of rotation about the vertical 
28
				axis. The third argument (r) is the length of the vector. */
28
				axis. The third argument (r) is the length of the vector. */
29
		void set_spherical( T, T, T);
29
		void set_spherical( T, T, T);
30
		
30
		
31
	};
31
	};
32
 
32
 
33
	/// Returns cross product of arguments
33
	/// Returns cross product of arguments
34
	template<class T, class V>
34
	template<class T, class V>
35
	inline V cross( const ArithVec3Float<T,V>& x, 
35
	inline V cross( const ArithVec3Float<T,V>& x, 
36
									const ArithVec3Float<T,V>& y ) 
36
									const ArithVec3Float<T,V>& y ) 
37
	{
37
	{
38
		return V( x[1] * y[2] - x[2] * y[1], 
38
		return V( x[1] * y[2] - x[2] * y[1], 
39
							x[2] * y[0] - x[0] * y[2], 
39
							x[2] * y[0] - x[0] * y[2], 
40
							x[0] * y[1] - x[1] * y[0] );
40
							x[0] * y[1] - x[1] * y[0] );
41
	}
41
	}
42
 
42
 
43
	/** Compute basis of orthogonal plane.
43
	/** Compute basis of orthogonal plane.
44
			Given a vector Compute two vectors that are orthogonal to it and 
44
			Given a vector compute two vectors that are orthogonal to it and 
45
			to each other. */
45
			to each other. */
46
	template<class T, class V>
46
	template<class T, class V>
47
	void orthogonal(const ArithVec3Float<T,V>&,
47
	void orthogonal(const ArithVec3Float<T,V>&,
48
									ArithVec3Float<T,V>&,
48
									ArithVec3Float<T,V>&,
49
									ArithVec3Float<T,V>&);
49
									ArithVec3Float<T,V>&);
50
 
50
 
-
 
51
  /** Build an orthonormal basis from a 3d unit vector [Frisvad 2012].
-
 
52
      Given a unit vector compute two unit vectors that are orthogonal to
-
 
53
      it and to each other. */
-
 
54
  template<class T, class V>
-
 
55
  void onb(const ArithVec3Float<T,V>&,
-
 
56
           ArithVec3Float<T,V>&,
-
 
57
           ArithVec3Float<T,V>&);
51
}
58
}
52
 
59
 
53
#endif
60
#endif
54
 
61
 
55
 
62