Subversion Repositories gelsvn

Rev

Rev 12 | 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
 
12 jab 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
 
12 jab 13
    public:
14
 
15
      ArithVecFloat() 
16
	{
10 jab 17
#ifndef NDEBUG
12 jab 18
	  for_all_i(data[i]=CGLA_INIT_VALUE);
10 jab 19
#endif
12 jab 20
	}
21
 
22
      ArithVecFloat(T a): 
23
	ArithVec<T,V,N>(a) {}
2 bj 24
 
12 jab 25
      ArithVecFloat(T a, T b): 
26
	ArithVec<T,V,N>(a,b) {}
2 bj 27
 
12 jab 28
      ArithVecFloat(T a, T b, T c): 
29
	ArithVec<T,V,N>(a,b,c) {}
2 bj 30
 
12 jab 31
      ArithVecFloat(T a, T b, T c, T d): 
32
	ArithVec<T,V,N>(a,b,c,d) {}
2 bj 33
 
12 jab 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
    };
2 bj 47
 
12 jab 48
  /// Returns normalized vector
49
  template<class T, class V, int N>
50
    inline T length(const ArithVecFloat<T,V,N>& v) 
2 bj 51
    {
12 jab 52
      return v.length();
2 bj 53
    }
12 jab 54
 
55
 
56
  /// Returns normalized vector
57
  template<class T, class V, int N>
58
    inline V normalize(const ArithVecFloat<T,V,N>& v) 
2 bj 59
    {
12 jab 60
      return v/v.length();
2 bj 61
    }
10 jab 62
#undef for_all_i
2 bj 63
}
64
 
65
#endif
66