Subversion Repositories gelsvn

Rev

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

Rev Author Line No. Line
2 bj 1
#ifndef __CGLA__ARITHVECFLOAT_H__
2
#define __CGLA__ARITHVECFLOAT_H__
3
 
4
#include "ArithVec.h"
5
 
6
namespace CGLA {
7
 
8
	template<class T, class V, int N>
9
	class ArithVecFloat: public ArithVec<T,V,N>
10
	{
11
	public:
12
 
13
		ArithVecFloat() {}
14
 
15
		ArithVecFloat(T a): 
16
			ArithVec<T,V,N>(a) {}
17
 
18
		ArithVecFloat(T a, T b): 
19
			ArithVec<T,V,N>(a,b) {}
20
 
21
		ArithVecFloat(T a, T b, T c): 
22
			ArithVec<T,V,N>(a,b,c) {}
23
 
24
		ArithVecFloat(T a, T b, T c, T d): 
25
			ArithVec<T,V,N>(a,b,c,d) {}
26
 
27
		/// Compute Euclidean length.
28
		T length() const 
29
    {
30
      return sqrt(sqr_length(*this));
31
    }
32
 
33
		/// Normalize vector.
34
		void normalize() 
35
    {
36
      (*this) /= length();
37
    }
38
 
39
	};
40
 
41
	/// Returns normalized vector
42
	template<class T, class V, int N>
43
	inline T length(const ArithVecFloat<T,V,N>& v) 
44
	{
45
		return v.length();
46
	}
47
 
48
 
49
	/// Returns normalized vector
50
	template<class T, class V, int N>
51
	inline V normalize(const ArithVecFloat<T,V,N>& v) 
52
	{
53
		return v/v.length();
54
	}
55
 
56
}
57
 
58
#endif
59