Subversion Repositories gelsvn

Rev

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