Subversion Repositories gelsvn

Rev

Rev 2 | Rev 43 | Go to most recent revision | Details | Compare with Previous | 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
	{
10 jab 11
#define for_all_i(expr) for(int i=0;i<N;i++) {expr;}
12
 
2 bj 13
	public:
14
 
10 jab 15
		ArithVecFloat() 
16
			{
17
#ifndef NDEBUG
18
			for_all_i(data[i]=CGLA_INIT_VALUE);
19
#endif
20
			}
2 bj 21
 
22
		ArithVecFloat(T a): 
23
			ArithVec<T,V,N>(a) {}
24
 
25
		ArithVecFloat(T a, T b): 
26
			ArithVec<T,V,N>(a,b) {}
27
 
28
		ArithVecFloat(T a, T b, T c): 
29
			ArithVec<T,V,N>(a,b,c) {}
30
 
31
		ArithVecFloat(T a, T b, T c, T d): 
32
			ArithVec<T,V,N>(a,b,c,d) {}
33
 
34
		/// Compute Euclidean length.
35
		T length() const 
36
    {
37
      return sqrt(sqr_length(*this));
38
    }
39
 
40
		/// Normalize vector.
41
		void normalize() 
42
    {
43
      (*this) /= length();
44
    }
45
 
46
	};
47
 
48
	/// Returns normalized vector
49
	template<class T, class V, int N>
50
	inline T length(const ArithVecFloat<T,V,N>& v) 
51
	{
52
		return v.length();
53
	}
54
 
55
 
56
	/// Returns normalized vector
57
	template<class T, class V, int N>
58
	inline V normalize(const ArithVecFloat<T,V,N>& v) 
59
	{
60
		return v/v.length();
61
	}
10 jab 62
#undef for_all_i
2 bj 63
}
64
 
65
#endif
66