Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
#ifndef __CGLA__ARITHVEC2FLOAT_H__
2
#define __CGLA__ARITHVEC2FLOAT_H__
3
 
4
#include "ArithVecFloat.h"
5
 
6
namespace CGLA {
7
 
8
	template<class T, class V>
9
	class ArithVec2Float: public ArithVecFloat<T,V,2>
10
	{
11
	public:
12
 
13
		/// Construct a 2D float vector.
14
		ArithVec2Float(T a, T b): ArithVecFloat<T,V,2>(a,b) {}
15
 
16
		/// Construct a 2D float vector.
17
		ArithVec2Float() {}		
18
	};
19
 
20
	/// Returns normalized vector
21
	template<class T, class V>
22
	inline V normalize(const ArithVec2Float<T,V>& v) 
23
	{
24
		return v/v.length();
25
	}
26
 
27
	/// Rotates vector 90 degrees to obtain orthogonal vector
28
	template<class T, class V>
29
	inline V orthogonal(const ArithVec2Float<T,V>& v) 
30
	{
31
		return V(-v[1],v[0]);
32
	}
33
 
34
	// Computes (scalar) cross product from two vectors	
35
	template<class T, class V>
36
	inline T cross(const ArithVec2Float<T,V>& a, 
37
								 const ArithVec2Float<T,V>& b)
38
	{
39
		return a[0]*b[1]-a[1]*b[0];
40
	}
41
 
42
	/** The two last (scalar) arguments are the linear combination of 
43
			the two first arguments (vectors) which produces the third argument.
44
			*/
45
	template<class T, class V>
46
	bool linear_combine(const ArithVec2Float<T,V>& a,
47
											const ArithVec2Float<T,V>& b,
48
											const ArithVec2Float<T,V>& c,
49
											T&,
50
											T&);
51
 
52
 
53
}
54
 
55
#endif
56