Subversion Repositories gelsvn

Rev

Rev 43 | Rev 125 | 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
 
45 jab 8
  template<class T, class V, unsigned int N>
12 jab 9
    class ArithVecFloat: public ArithVec<T,V,N>
10
    {
11
    public:
12
 
13
      ArithVecFloat() 
14
	{
10 jab 15
#ifndef NDEBUG
43 jrf 16
	  std::fill_n(data, N, CGLA_INIT_VALUE);
10 jab 17
#endif
12 jab 18
	}
19
 
20
      ArithVecFloat(T a): 
21
	ArithVec<T,V,N>(a) {}
2 bj 22
 
12 jab 23
      ArithVecFloat(T a, T b): 
24
	ArithVec<T,V,N>(a,b) {}
2 bj 25
 
12 jab 26
      ArithVecFloat(T a, T b, T c): 
27
	ArithVec<T,V,N>(a,b,c) {}
2 bj 28
 
12 jab 29
      ArithVecFloat(T a, T b, T c, T d): 
30
	ArithVec<T,V,N>(a,b,c,d) {}
2 bj 31
 
12 jab 32
      /// Compute Euclidean length.
33
      T length() const 
34
	{
35
	  return sqrt(sqr_length(*this));
36
	}
37
 
38
      /// Normalize vector.
39
      void normalize() 
40
	{
41
	  (*this) /= length();
42
	}
43
 
44
    };
2 bj 45
 
12 jab 46
  /// Returns normalized vector
45 jab 47
  template<class T, class V, unsigned int N>
12 jab 48
    inline T length(const ArithVecFloat<T,V,N>& v) 
2 bj 49
    {
12 jab 50
      return v.length();
2 bj 51
    }
12 jab 52
 
53
 
54
  /// Returns normalized vector
45 jab 55
  template<class T, class V, unsigned int N>
12 jab 56
    inline V normalize(const ArithVecFloat<T,V,N>& v) 
2 bj 57
    {
12 jab 58
      return v/v.length();
2 bj 59
    }
60
}
61
 
62
#endif
63