Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Audio::TMatrix3< T > Class Template Reference

#include <Matrix.h>

Public Member Functions

 TMatrix3 ()
 
 TMatrix3 (T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33)
 
 TMatrix3 (T s)
 
template<typename Y >
 TMatrix3 (const TMatrix3< Y > &o)
 
template<typename Y >
 TMatrix3 (const TVector3< Y > &c1, const TVector3< Y > &c2, const TVector3< Y > &c3)
 
template<typename Y >
TMatrix3< T > & operator= (const TMatrix3< Y > &o)
 
TMatrix3< T > & operator+= (const TMatrix3< T > &o)
 
TMatrix3< T > & operator-= (const TMatrix3< T > &o)
 
TMatrix3< T > & operator*= (const TMatrix3< T > &o)
 
TVector3< T > & operator*= (T t)
 
TMatrix3< T > & operator/= (const TMatrix3< T > &other)
 
TMatrix3< T > & operator/= (T t)
 
TMatrix3< T > operator+ (const TMatrix3< T > &o) const
 
TMatrix3< T > operator- (const TMatrix3< T > &o) const
 
TMatrix3< T > operator* (const TMatrix3< T > &o) const
 
TMatrix3< T > operator/ (const TMatrix3< T > &other) const
 
TMatrix3< T > operator* (T t) const
 
TMatrix3< T > operator/ (T t) const
 
template<typename Y >
TVector3< Y > operator* (const TVector3< Y > &t) const
 
TMatrix3< T > inverse () const
 
TMatrix3< T > transpose () const
 

Public Attributes

m [3][3]
 

Detailed Description

template<typename T>
class Audio::TMatrix3< T >

Definition at line 12 of file Matrix.h.

Constructor & Destructor Documentation

template<typename T>
Audio::TMatrix3< T >::TMatrix3 ( )
inline

Definition at line 16 of file Matrix.h.

16 {}
template<typename T>
Audio::TMatrix3< T >::TMatrix3 ( m11,
m12,
m13,
m21,
m22,
m23,
m31,
m32,
m33 
)
inline

Definition at line 17 of file Matrix.h.

18  {
19  m[0][0] = m11; m[0][1] = m12; m[0][2] = m13;
20  m[1][0] = m21; m[1][1] = m22; m[1][2] = m23;
21  m[2][0] = m31; m[2][1] = m32; m[2][2] = m33;
22  }
template<typename T>
Audio::TMatrix3< T >::TMatrix3 ( s)
inlineexplicit

Definition at line 23 of file Matrix.h.

24  {
25  m[0][0] = s; m[0][1] = 0; m[0][2] = 0;
26  m[1][0] = 0; m[1][1] = s; m[1][2] = 0;
27  m[2][0] = 0; m[2][1] = 0; m[2][2] = s;
28  }
template<typename T>
template<typename Y >
Audio::TMatrix3< T >::TMatrix3 ( const TMatrix3< Y > &  o)
inline

Definition at line 31 of file Matrix.h.

32  {
33  m[0][0] = o.m[0][0]; m[0][1] = o.m[0][1]; m[0][2] = o.m[0][2];
34  m[1][0] = o.m[1][0]; m[1][1] = o.m[1][1]; m[1][2] = o.m[1][2];
35  m[2][0] = o.m[2][0]; m[2][1] = o.m[2][1]; m[2][2] = o.m[2][2];
36  }
template<typename T>
template<typename Y >
Audio::TMatrix3< T >::TMatrix3 ( const TVector3< Y > &  c1,
const TVector3< Y > &  c2,
const TVector3< Y > &  c3 
)
inline

Definition at line 39 of file Matrix.h.

40  {
41  m[0][0] = c1.x; m[0][1] = c2.x; m[0][2] = c3.x;
42  m[1][0] = c1.y; m[1][1] = c2.y; m[1][2] = c3.y;
43  m[2][0] = c1.z; m[2][1] = c2.z; m[2][2] = c3.z;
44  }

Member Function Documentation

template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::inverse ( ) const
inline

Definition at line 166 of file Matrix.h.

Referenced by Audio::TMatrix3< Scalar >::operator/(), and Audio::TMatrix3< Scalar >::operator/=().

167  {
168  TMatrix3<T> rv;
169 
170  /*
171  compute adjoint matrix,
172  then divide by the determinant
173  */
174 
175  //determinant
176  float det =
177  +m[0][0] * m[1][1] * m[2][2]
178  +m[1][0] * m[2][1] * m[0][2]
179  +m[2][0] * m[0][1] * m[1][2]
180 
181  -m[0][2] * m[1][1] * m[2][0]
182  -m[1][2] * m[2][1] * m[0][0]
183  -m[2][2] * m[0][1] * m[1][0];
184  float idet = T(1) / det;
185 
186  rv.m[0][0] =+(m[1][1] * m[2][2] - m[1][2] * m[2][1]) * idet;
187  rv.m[0][1] =-(m[1][0] * m[2][2] - m[1][2] * m[2][0]) * idet;
188  rv.m[0][2] =+(m[1][0] * m[2][1] - m[1][1] * m[2][0]) * idet;
189 
190  rv.m[1][0] =-(m[0][1] * m[2][2] - m[0][2] * m[2][1]) * idet;
191  rv.m[1][1] =+(m[0][0] * m[2][2] - m[0][2] * m[2][0]) * idet;
192  rv.m[1][2] =-(m[0][0] * m[2][1] - m[0][1] * m[2][0]) * idet;
193 
194  rv.m[2][0] =+(m[0][1] * m[1][2] - m[0][2] * m[1][1]) * idet;
195  rv.m[2][1] =-(m[0][0] * m[1][2] - m[0][2] * m[1][0]) * idet;
196  rv.m[2][2] =+(m[0][0] * m[1][1] - m[0][1] * m[1][0]) * idet;
197 
198  return rv;
199  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator* ( const TMatrix3< T > &  o) const
inline

Definition at line 126 of file Matrix.h.

127  {
128  #define DOT(m,om,r,c) (m[r][0]*om[0][c] + m[r][1]*om[1][c] + m[r][2]*om[2][c])
129  return TMatrix3<T>(
130  DOT(m,o.m,0,0), DOT(m,o.m,0,1), DOT(m,o.m,0,2),
131  DOT(m,o.m,1,0), DOT(m,o.m,1,1), DOT(m,o.m,1,2),
132  DOT(m,o.m,2,0), DOT(m,o.m,2,1), DOT(m,o.m,2,2)
133  );
134  #undef DOT
135  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator* ( t) const
inline

Definition at line 142 of file Matrix.h.

143  {
144  return TMatrix3<T>(
145  m[0][0]*t, m[0][1]*t, m[0][2]*t,
146  m[1][0]*t, m[1][1]*t, m[1][2]*t,
147  m[2][0]*t, m[2][1]*t, m[2][2]*t
148  );
149  }
template<typename T>
template<typename Y >
TVector3<Y> Audio::TMatrix3< T >::operator* ( const TVector3< Y > &  t) const
inline

Definition at line 157 of file Matrix.h.

158  {
159  return TVector3<Y>(
160  m[0][0]*t.x + m[0][1]*t.y + m[0][2]*t.z,
161  m[1][0]*t.x + m[1][1]*t.y + m[1][2]*t.z,
162  m[2][0]*t.x + m[2][1]*t.y + m[2][2]*t.z
163  );
164  }
template<typename T>
TMatrix3<T>& Audio::TMatrix3< T >::operator*= ( const TMatrix3< T > &  o)
inline

Definition at line 71 of file Matrix.h.

72  {
73  #define DOT(m,om,r,c) (m[r][0]*om[0][c] + m[r][1]*om[1][c] + m[r][2]*om[2][c])
74  TMatrix3<T> rv;
75  rv.m[0][0] = DOT(m,o.m,0,0);
76  rv.m[0][1] = DOT(m,o.m,0,1);
77  rv.m[0][2] = DOT(m,o.m,0,2);
78  rv.m[1][0] = DOT(m,o.m,1,0);
79  rv.m[1][1] = DOT(m,o.m,1,1);
80  rv.m[1][2] = DOT(m,o.m,1,2);
81  rv.m[2][0] = DOT(m,o.m,2,0);
82  rv.m[2][1] = DOT(m,o.m,2,1);
83  rv.m[2][2] = DOT(m,o.m,2,2);
84  #undef DOT
85  return *this;
86  }
template<typename T>
TVector3<T>& Audio::TMatrix3< T >::operator*= ( t)
inline

Definition at line 88 of file Matrix.h.

89  {
90  m[0][0] *= t; m[0][1] *= t; m[0][2] *= t;
91  m[1][0] *= t; m[1][1] *= t; m[1][2] *= t;
92  m[2][0] *= t; m[2][1] *= t; m[2][2] *= t;
93  return *this;
94  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator+ ( const TMatrix3< T > &  o) const
inline

Definition at line 108 of file Matrix.h.

109  {
110  return TMatrix3<T>(
111  m[0][0]+o.m[0][0], m[0][1]+o.m[0][1], m[0][2]+o.m[0][2],
112  m[1][0]+o.m[1][0], m[1][1]+o.m[1][1], m[1][2]+o.m[1][2],
113  m[2][0]+o.m[2][0], m[2][1]+o.m[2][1], m[2][2]+o.m[2][2]
114  );
115  }
template<typename T>
TMatrix3<T>& Audio::TMatrix3< T >::operator+= ( const TMatrix3< T > &  o)
inline

Definition at line 55 of file Matrix.h.

56  {
57  m[0][0] += o.m[0][0]; m[0][1] += o.m[0][1]; m[0][2] += o.m[0][2];
58  m[1][0] += o.m[1][0]; m[1][1] += o.m[1][1]; m[1][2] += o.m[1][2];
59  m[2][0] += o.m[2][0]; m[2][1] += o.m[2][1]; m[2][2] += o.m[2][2];
60  return *this;
61  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator- ( const TMatrix3< T > &  o) const
inline

Definition at line 117 of file Matrix.h.

118  {
119  return TMatrix3<T>(
120  m[0][0]-o.m[0][0], m[0][1]-o.m[0][1], m[0][2]-o.m[0][2],
121  m[1][0]-o.m[1][0], m[1][1]-o.m[1][1], m[1][2]-o.m[1][2],
122  m[2][0]-o.m[2][0], m[2][1]-o.m[2][1], m[2][2]-o.m[2][2]
123  );
124  }
template<typename T>
TMatrix3<T>& Audio::TMatrix3< T >::operator-= ( const TMatrix3< T > &  o)
inline

Definition at line 63 of file Matrix.h.

64  {
65  m[0][0] -= o.m[0][0]; m[0][1] -= o.m[0][1]; m[0][2] -= o.m[0][2];
66  m[1][0] -= o.m[1][0]; m[1][1] -= o.m[1][1]; m[1][2] -= o.m[1][2];
67  m[2][0] -= o.m[2][0]; m[2][1] -= o.m[2][1]; m[2][2] -= o.m[2][2];
68  return *this;
69  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator/ ( const TMatrix3< T > &  other) const
inline

Definition at line 137 of file Matrix.h.

138  {
139  return (*this) * other.inverse();
140  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::operator/ ( t) const
inline

Definition at line 151 of file Matrix.h.

152  {
153  return (*this) * (T(1) / t);
154  }
template<typename T>
TMatrix3<T>& Audio::TMatrix3< T >::operator/= ( const TMatrix3< T > &  other)
inline

Definition at line 96 of file Matrix.h.

97  {
98  (*this) *= other.inverse();
99  return *this;
100  }
template<typename T>
TMatrix3<T>& Audio::TMatrix3< T >::operator/= ( t)
inline

Definition at line 102 of file Matrix.h.

103  {
104  (*this) *= T(1) / t;
105  return *this;
106  }
template<typename T>
template<typename Y >
TMatrix3<T>& Audio::TMatrix3< T >::operator= ( const TMatrix3< Y > &  o)
inline

Definition at line 47 of file Matrix.h.

48  {
49  m[0][0] = o.m[0][0]; m[0][1] = o.m[0][1]; m[0][2] = o.m[0][2];
50  m[1][0] = o.m[1][0]; m[1][1] = o.m[1][1]; m[1][2] = o.m[1][2];
51  m[2][0] = o.m[2][0]; m[2][1] = o.m[2][1]; m[2][2] = o.m[2][2];
52  return *this;
53  }
template<typename T>
TMatrix3<T> Audio::TMatrix3< T >::transpose ( ) const
inline

Definition at line 201 of file Matrix.h.

202  {
203  return TMatrix3<T>(
204  m[0][0], m[1][0], m[2][0],
205  m[0][1], m[1][1], m[2][1],
206  m[0][2], m[1][2], m[2][2]
207  );
208  }

Member Data Documentation


The documentation for this class was generated from the following file: