Subversion Repositories gelsvn

Rev

Rev 67 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
#ifndef __CGLA_ARITHSQMAT3X3FLOAT_H__
2
#define __CGLA_ARITHSQMAT3X3FLOAT_H__
3
 
4
#include "ExceptionStandard.h"
5
#include "CGLA.h"
6
#include "Vec3f.h"
7
#include "ArithSqMatFloat.h"
8
 
12 jab 9
namespace CGLA 
10
{
2 bj 11
 
12 jab 12
  CGLA_DERIVEEXCEPTION(Mat3x3fException)
13
    CGLA_DERIVEEXCEPTION(Mat3x3fSingular)
2 bj 14
 
94 bj 15
    /** \brief 3 by 3 float matrix template.
16
 
17
		This class template will typically be used for rotation or
18
		scaling matrices for 3D vectors. */
12 jab 19
    template<class V, class M>
20
    class ArithSqMat3x3Float: public ArithSqMatFloat<V, M, 3>
21
    {
22
    public:
2 bj 23
 
12 jab 24
      /// Vector type
25
      typedef V VectorType;
2 bj 26
 
12 jab 27
      /// The type of a matrix element
28
      typedef typename V::ScalarType ScalarType;
2 bj 29
 
12 jab 30
    public:
2 bj 31
 
12 jab 32
      /// Construct matrix from 3 Vec3f vectors.
33
      ArithSqMat3x3Float(V _a, V _b, V _c): 
34
	ArithSqMatFloat<V, M, 3> (_a,_b,_c) {}
2 bj 35
 
12 jab 36
      /// Construct the 0 matrix
37
      ArithSqMat3x3Float() {}
2 bj 38
 
12 jab 39
      /// Construct a matrix from a single scalar value.
40
      explicit ArithSqMat3x3Float(ScalarType a): 
41
	ArithSqMatFloat<V, M, 3>(a) {}
2 bj 42
 
12 jab 43
    };
2 bj 44
 
12 jab 45
  /// Invert 3x3 matrix
46
  template<class V, class M>
47
    M invert(const ArithSqMat3x3Float<V,M>&);
2 bj 48
 
12 jab 49
  /** Compute determinant. There is a more generic function for
50
      computing determinants of square matrices (ArithSqMat). This one
51
      is faster but works only on Mat3x3f */
52
  template<class V, class M>
53
    inline 
54
    typename ArithSqMat3x3Float<V,M>::ScalarType
55
    determinant(const ArithSqMat3x3Float<V,M>& m)
56
    {
57
      return 
58
	m[0][0]*m[1][1]*m[2][2] +
59
	m[0][1]*m[1][2]*m[2][0] +
60
	m[0][2]*m[1][0]*m[2][1] -
61
	m[0][2]*m[1][1]*m[2][0] -
62
	m[0][0]*m[1][2]*m[2][1] -
63
	m[0][1]*m[1][0]*m[2][2] ;
64
    }
2 bj 65
 
66
 
67
}
68
#endif
69
 
70
 
71
 
72
 
73
 
74
 
75