Subversion Repositories gelsvn

Rev

Rev 45 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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