#include <Matrix4.h>
Public Member Functions | |
| Matrix4 () | |
| Construct an identity matrix. | |
| Matrix4 (const tReal &v00, const tReal &v10, const tReal &v20, const tReal &v30, const tReal &v01, const tReal &v11, const tReal &v21, const tReal &v31, const tReal &v02, const tReal &v12, const tReal &v22, const tReal &v32, const tReal &v03, const tReal &v13, const tReal &v23, const tReal &v33) | |
| Construct a matrix using the given values. | |
| Matrix4 & | Translate (const pcce::Vector3 &v) |
| Concatenate a translation into the current matrix. | |
| Matrix4 & | Scale (const tReal &scalar) |
| Concatenate a scale into the current matrix. | |
| Matrix4 & | Scale (const pcce::Vector3 &v) |
| Concatenate a scale into the current matrix. | |
| Matrix4 & | RotateX (const tReal &radians) |
| Concatenate a rotation about the X-axis into the current matrix. | |
| Matrix4 & | RotateY (const tReal &radians) |
| Concatenate a rotation about the Y-axis into the current matrix. | |
| Matrix4 & | RotateZ (const tReal &radians) |
| Concatenate a rotation about the Z-axis into the current matrix. | |
| Matrix4 & | Rotate (const Vector3 &axis, const tReal &radians) |
| Concatenate a rotation about a custom axis into the current matrix. | |
| Matrix4 | GetTranspose () |
| const tReal & | operator() (const unsigned short &i, const unsigned short &j) const |
| Operator to index into a const matrix. | |
| tReal & | operator() (const unsigned short &i, const unsigned short &j) |
| Operator to index into a matrix. | |
| Matrix4 | operator* (const Matrix4 &rhs) |
| Concatenate two 4x4 matrices. | |
| Vector4 | operator* (const Vector4 &rhs) |
| Transform a Vector4 by the matrix. | |
| Matrix4 | operator* (const tReal scalar) |
| Matrix4 | operator+ (const Matrix4 &rhs) |
| Matrix4 | operator- (const Matrix4 &rhs) |
| bool | operator== (const Matrix4 &rhs) const |
| Matrix4 equals operator. | |
| bool | operator!= (const Matrix4 &rhs) const |
| Matrix4 not equal operator. | |
| void | SetValues (const tReal &v00, const tReal &v10, const tReal &v20, const tReal &v30, const tReal &v01, const tReal &v11, const tReal &v21, const tReal &v31, const tReal &v02, const tReal &v12, const tReal &v22, const tReal &v32, const tReal &v03, const tReal &v13, const tReal &v23, const tReal &v33) |
| void | Concatenate (const Matrix4 &rhs) |
| void | SetTranslate (const pcce::Vector3 &v) |
| Set the translate values. | |
| void | SetScale (const pcce::Vector3 &v) |
| Set the scale values. | |
| void | SetRotateX (const tReal &radians) |
| Set the X-axis rotation values. | |
| void | SetRotateY (const tReal &radians) |
| Set the Y-axis rotation values. | |
| void | SetRotateZ (const tReal &radians) |
| Set the Z-axis rotation values. | |
Private Member Functions | |
| unsigned short | GetIndex (const unsigned short &i, const unsigned short &j) const |
| const tReal & | GetValue (const unsigned short &i, const unsigned short &j) const |
| tReal & | GetValue (const unsigned short &i, const unsigned short &j) |
Private Attributes | |
| tReal | mValues [TotalValues] |
Static Private Attributes | |
| static const unsigned short | TotalValues = 16 |
| static const unsigned short | ValuesPerRow = 4 |
Definition at line 45 of file Matrix4.h.
| Matrix4::Matrix4 | ( | ) |
Construct an identity matrix.
Definition at line 43 of file Matrix4.cpp.
References GetValue().
Referenced by GetTranspose().
00043 { 00044 GetValue(0, 0) = 1.0; 00045 GetValue(1, 0) = 0.0; 00046 GetValue(2, 0) = 0.0; 00047 GetValue(3, 0) = 0.0; 00048 00049 GetValue(0, 1) = 0.0; 00050 GetValue(1, 1) = 1.0; 00051 GetValue(2, 1) = 0.0; 00052 GetValue(3, 1) = 0.0; 00053 00054 GetValue(0, 2) = 0.0; 00055 GetValue(1, 2) = 0.0; 00056 GetValue(2, 2) = 1.0; 00057 GetValue(3, 2) = 0.0; 00058 00059 GetValue(0, 3) = 0.0; 00060 GetValue(1, 3) = 0.0; 00061 GetValue(2, 3) = 0.0; 00062 GetValue(3, 3) = 1.0; 00063 }
| Matrix4::Matrix4 | ( | const tReal & | v00, | |
| const tReal & | v10, | |||
| const tReal & | v20, | |||
| const tReal & | v30, | |||
| const tReal & | v01, | |||
| const tReal & | v11, | |||
| const tReal & | v21, | |||
| const tReal & | v31, | |||
| const tReal & | v02, | |||
| const tReal & | v12, | |||
| const tReal & | v22, | |||
| const tReal & | v32, | |||
| const tReal & | v03, | |||
| const tReal & | v13, | |||
| const tReal & | v23, | |||
| const tReal & | v33 | |||
| ) |
Construct a matrix using the given values.
Definition at line 65 of file Matrix4.cpp.
References SetValues().
00070 { 00071 SetValues( 00072 v00, v10, v20, v30, 00073 v01, v11, v21, v31, 00074 v02, v12, v22, v32, 00075 v03, v13, v23, v33); 00076 }
| Matrix4 & Matrix4::Translate | ( | const pcce::Vector3 & | v | ) |
Concatenate a translation into the current matrix.
Definition at line 79 of file Matrix4.cpp.
References Concatenate(), and SetTranslate().
00079 { 00080 Matrix4 m; 00081 m.SetTranslate(v); 00082 00083 Concatenate(m); 00084 return *this; 00085 }
| Matrix4 & Matrix4::Scale | ( | const pcce::Vector3 & | v | ) |
Concatenate a scale into the current matrix.
Definition at line 91 of file Matrix4.cpp.
References Concatenate(), and SetScale().
00091 { 00092 Matrix4 m; 00093 m.SetScale(v); 00094 00095 Concatenate(m); 00096 return *this; 00097 }
Concatenate a rotation about the X-axis into the current matrix.
Definition at line 99 of file Matrix4.cpp.
References Concatenate(), and SetRotateX().
00099 { 00100 Matrix4 m; 00101 m.SetRotateX(radians); 00102 00103 Concatenate(m); 00104 return *this; 00105 }
Concatenate a rotation about the Y-axis into the current matrix.
Definition at line 107 of file Matrix4.cpp.
References Concatenate(), and SetRotateY().
00107 { 00108 Matrix4 m; 00109 m.SetRotateY(radians); 00110 00111 Concatenate(m); 00112 return *this; 00113 }
Concatenate a rotation about the Z-axis into the current matrix.
Definition at line 115 of file Matrix4.cpp.
References Concatenate(), and SetRotateZ().
00115 { 00116 Matrix4 m; 00117 m.SetRotateZ(radians); 00118 00119 Concatenate(m); 00120 return *this; 00121 }
Concatenate a rotation about a custom axis into the current matrix.
Definition at line 123 of file Matrix4.cpp.
References PCCE_THROW.
00123 { 00124 PCCE_THROW("IMPLEMENT THIS!"); 00125 00126 return *this; 00127 }
| Matrix4 Matrix4::GetTranspose | ( | ) |
Definition at line 129 of file Matrix4.cpp.
References GetValue(), and Matrix4().
00129 { 00130 return Matrix4( 00131 GetValue(0, 0), 00132 GetValue(0, 1), 00133 GetValue(0, 2), 00134 GetValue(0, 3), 00135 00136 GetValue(1, 0), 00137 GetValue(1, 1), 00138 GetValue(1, 2), 00139 GetValue(1, 3), 00140 00141 GetValue(2, 0), 00142 GetValue(2, 1), 00143 GetValue(2, 2), 00144 GetValue(2, 3), 00145 00146 GetValue(3, 0), 00147 GetValue(3, 1), 00148 GetValue(3, 2), 00149 GetValue(3, 3)); 00150 }
| const tReal & Matrix4::operator() | ( | const unsigned short & | i, | |
| const unsigned short & | j | |||
| ) | const |
Operator to index into a const matrix.
Use the () operator to access a particular element of the matrix. For example, "someVar = m(0, 0);" will set someVar to the first row, first column of the matrix.
Definition at line 152 of file Matrix4.cpp.
References GetValue(), PCCE_CHECK, and ValuesPerRow.
00152 { 00153 PCCE_CHECK(i < ValuesPerRow, "Matrix4(): Index i out of bounds"); 00154 PCCE_CHECK(j < ValuesPerRow, "Matrix4(): Index j out of bounds"); 00155 return GetValue(i, j); 00156 }
| tReal & Matrix4::operator() | ( | const unsigned short & | i, | |
| const unsigned short & | j | |||
| ) |
Operator to index into a matrix.
Definition at line 158 of file Matrix4.cpp.
00158 { 00159 // This is from Effective C++ Item 3 00160 return const_cast< tReal& >( 00161 static_cast< const Matrix4& >(*this)(i, j)); 00162 }
Concatenate two 4x4 matrices.
Definition at line 164 of file Matrix4.cpp.
References Concatenate().
00164 { 00165 Matrix4 m = *this; 00166 m.Concatenate(rhs); 00167 return m; 00168 }
Transform a Vector4 by the matrix.
Definition at line 170 of file Matrix4.cpp.
References GetValue().
00170 { 00171 return Vector4( 00172 GetValue(0,0)*rhs(0) + GetValue(1,0)*rhs(1) + GetValue(2,0)*rhs(2) + GetValue(3, 0)*rhs(3), 00173 GetValue(0,1)*rhs(0) + GetValue(1,1)*rhs(1) + GetValue(2,1)*rhs(2) + GetValue(3, 1)*rhs(3), 00174 GetValue(0,2)*rhs(0) + GetValue(1,2)*rhs(1) + GetValue(2,2)*rhs(2) + GetValue(3, 2)*rhs(3), 00175 GetValue(0,3)*rhs(0) + GetValue(1,3)*rhs(1) + GetValue(2,3)*rhs(2) + GetValue(3, 3)*rhs(3)); 00176 }
Definition at line 178 of file Matrix4.cpp.
References mValues, and TotalValues.
00178 { 00179 Matrix4 result = *this; 00180 for (unsigned short i = 0; i < TotalValues; i++) { 00181 result.mValues[i] *= scalar; 00182 } 00183 return result; 00184 }
Definition at line 186 of file Matrix4.cpp.
References mValues, and TotalValues.
00186 { 00187 Matrix4 result = *this; 00188 for (unsigned short i = 0; i < TotalValues; i++) { 00189 result.mValues[i] += rhs.mValues[i]; 00190 } 00191 return result; 00192 }
Definition at line 194 of file Matrix4.cpp.
References mValues, and TotalValues.
00194 { 00195 Matrix4 result = *this; 00196 for (unsigned short i = 0; i < TotalValues; i++) { 00197 result.mValues[i] -= rhs.mValues[i]; 00198 } 00199 return result; 00200 }
| bool Matrix4::operator== | ( | const Matrix4 & | rhs | ) | const |
Matrix4 equals operator.
The == operator compares each element of the matrices using SameReal(). Note: Due to the comparison method that SameReal() uses, "m1 == m2" may be true, "m2 == m3" may be true, but "m1 == m3" may be false.
Definition at line 202 of file Matrix4.cpp.
References mValues, pcce::SameReal(), and TotalValues.
00202 { 00203 for (unsigned short i = 0; i < TotalValues; i++) { 00204 if (!SameReal(mValues[i], rhs.mValues[i])) { 00205 return false; 00206 } 00207 } 00208 return true; 00209 }
| bool Matrix4::operator!= | ( | const Matrix4 & | rhs | ) | const |
Matrix4 not equal operator.
The != operator compares each element of the matrices using SameReal(). Note: Due to the comparison method that SameReal() uses, "m1 != m2" may be true, "m2 != m3" may be true, but "m1 != m3" may be false.
Definition at line 211 of file Matrix4.cpp.
| void Matrix4::SetValues | ( | const tReal & | v00, | |
| const tReal & | v10, | |||
| const tReal & | v20, | |||
| const tReal & | v30, | |||
| const tReal & | v01, | |||
| const tReal & | v11, | |||
| const tReal & | v21, | |||
| const tReal & | v31, | |||
| const tReal & | v02, | |||
| const tReal & | v12, | |||
| const tReal & | v22, | |||
| const tReal & | v32, | |||
| const tReal & | v03, | |||
| const tReal & | v13, | |||
| const tReal & | v23, | |||
| const tReal & | v33 | |||
| ) |
Definition at line 215 of file Matrix4.cpp.
References GetValue().
Referenced by Concatenate(), and Matrix4().
00220 { 00221 GetValue(0, 0) = v00; 00222 GetValue(1, 0) = v10; 00223 GetValue(2, 0) = v20; 00224 GetValue(3, 0) = v30; 00225 00226 GetValue(0, 1) = v01; 00227 GetValue(1, 1) = v11; 00228 GetValue(2, 1) = v21; 00229 GetValue(3, 1) = v31; 00230 00231 GetValue(0, 2) = v02; 00232 GetValue(1, 2) = v12; 00233 GetValue(2, 2) = v22; 00234 GetValue(3, 2) = v32; 00235 00236 GetValue(0, 3) = v03; 00237 GetValue(1, 3) = v13; 00238 GetValue(2, 3) = v23; 00239 GetValue(3, 3) = v33; 00240 }
| void Matrix4::Concatenate | ( | const Matrix4 & | rhs | ) |
Definition at line 242 of file Matrix4.cpp.
References GetValue(), and SetValues().
Referenced by operator*(), RotateX(), RotateY(), RotateZ(), Scale(), and Translate().
00242 { 00243 SetValues( 00244 GetValue(0,0)*rhs(0,0) + GetValue(1,0)*rhs(0,1) + GetValue(2,0)*rhs(0,2) + GetValue(3,0)*rhs(0,3), 00245 GetValue(0,0)*rhs(1,0) + GetValue(1,0)*rhs(1,1) + GetValue(2,0)*rhs(1,2) + GetValue(3,0)*rhs(1,3), 00246 GetValue(0,0)*rhs(2,0) + GetValue(1,0)*rhs(2,1) + GetValue(2,0)*rhs(2,2) + GetValue(3,0)*rhs(2,3), 00247 GetValue(0,0)*rhs(3,0) + GetValue(1,0)*rhs(3,1) + GetValue(2,0)*rhs(3,2) + GetValue(3,0)*rhs(3,3), 00248 00249 GetValue(0,1)*rhs(0,0) + GetValue(1,1)*rhs(0,1) + GetValue(2,1)*rhs(0,2) + GetValue(3,1)*rhs(0,3), 00250 GetValue(0,1)*rhs(1,0) + GetValue(1,1)*rhs(1,1) + GetValue(2,1)*rhs(1,2) + GetValue(3,1)*rhs(1,3), 00251 GetValue(0,1)*rhs(2,0) + GetValue(1,1)*rhs(2,1) + GetValue(2,1)*rhs(2,2) + GetValue(3,1)*rhs(2,3), 00252 GetValue(0,1)*rhs(3,0) + GetValue(1,1)*rhs(3,1) + GetValue(2,1)*rhs(3,2) + GetValue(3,1)*rhs(3,3), 00253 00254 GetValue(0,2)*rhs(0,0) + GetValue(1,2)*rhs(0,1) + GetValue(2,2)*rhs(0,2) + GetValue(3,2)*rhs(0,3), 00255 GetValue(0,2)*rhs(1,0) + GetValue(1,2)*rhs(1,1) + GetValue(2,2)*rhs(1,2) + GetValue(3,2)*rhs(1,3), 00256 GetValue(0,2)*rhs(2,0) + GetValue(1,2)*rhs(2,1) + GetValue(2,2)*rhs(2,2) + GetValue(3,2)*rhs(2,3), 00257 GetValue(0,2)*rhs(3,0) + GetValue(1,2)*rhs(3,1) + GetValue(2,2)*rhs(3,2) + GetValue(3,2)*rhs(3,3), 00258 00259 GetValue(0,3)*rhs(0,0) + GetValue(1,3)*rhs(0,1) + GetValue(2,3)*rhs(0,2) + GetValue(3,3)*rhs(0,3), 00260 GetValue(0,3)*rhs(1,0) + GetValue(1,3)*rhs(1,1) + GetValue(2,3)*rhs(1,2) + GetValue(3,3)*rhs(1,3), 00261 GetValue(0,3)*rhs(2,0) + GetValue(1,3)*rhs(2,1) + GetValue(2,3)*rhs(2,2) + GetValue(3,3)*rhs(2,3), 00262 GetValue(0,3)*rhs(3,0) + GetValue(1,3)*rhs(3,1) + GetValue(2,3)*rhs(3,2) + GetValue(3,3)*rhs(3,3)); 00263 }
| void Matrix4::SetTranslate | ( | const pcce::Vector3 & | v | ) |
Set the translate values.
Sets the translate component of the matrix. Note: This does not concatenate other transforms, so it should probably only be called on an identity matrix. Call Matrix4::Translate to concatenate a translation with the current matrix.
Definition at line 265 of file Matrix4.cpp.
References GetValue().
Referenced by Translate().
00265 { 00266 GetValue(3, 0) = v(0); 00267 GetValue(3, 1) = v(1); 00268 GetValue(3, 2) = v(2); 00269 00270 }
| void Matrix4::SetScale | ( | const pcce::Vector3 & | v | ) |
Set the scale values.
Sets the scale component of the matrix. Note: This does not concatenate other transforms, so it should probably only be called on an identity matrix. Call Matrix4::Scale to concatenate a scale with the current matrix.
Definition at line 272 of file Matrix4.cpp.
References GetValue().
Referenced by Scale().
00272 { 00273 GetValue(0, 0) = v(0); 00274 GetValue(1, 1) = v(1); 00275 GetValue(2, 2) = v(2); 00276 }
| void Matrix4::SetRotateX | ( | const tReal & | radians | ) |
Set the X-axis rotation values.
Sets the X-axis rotation component of the matrix. Note: This does not concatenate other transforms, so it should probably only be called on an identity matrix. Call Matrix4::RotateX to concatenate a rotation with the current matrix.
Definition at line 278 of file Matrix4.cpp.
References GetValue().
Referenced by RotateX().
00278 { 00279 tReal cosVal = cos(radians); 00280 tReal sinVal = sin(radians); 00281 00282 GetValue(1, 1) = cosVal; 00283 GetValue(2, 1) = -sinVal; 00284 GetValue(1, 2) = sinVal; 00285 GetValue(2, 2) = cosVal; 00286 }
| void Matrix4::SetRotateY | ( | const tReal & | radians | ) |
Set the Y-axis rotation values.
Sets the Y-axis rotation component of the matrix. Note: This does not concatenate other transforms, so it should probably only be called on an identity matrix. Call Matrix4::RotateY to concatenate a rotation with the current matrix.
Definition at line 288 of file Matrix4.cpp.
References GetValue().
Referenced by RotateY().
00288 { 00289 tReal cosVal = cos(radians); 00290 tReal sinVal = sin(radians); 00291 00292 GetValue(0, 0) = cosVal; 00293 GetValue(2, 0) = sinVal; 00294 GetValue(0, 2) = -sinVal; 00295 GetValue(2, 2) = cosVal; 00296 }
| void Matrix4::SetRotateZ | ( | const tReal & | radians | ) |
Set the Z-axis rotation values.
Sets the Z-axis rotation component of the matrix. Note: This does not concatenate other transforms, so it should probably only be called on an identity matrix. Call Matrix4::RotateZ to concatenate a rotation with the current matrix.
Definition at line 298 of file Matrix4.cpp.
References GetValue().
Referenced by RotateZ().
00298 { 00299 tReal cosVal = cos(radians); 00300 tReal sinVal = sin(radians); 00301 00302 GetValue(0, 0) = cosVal; 00303 GetValue(1, 0) = -sinVal; 00304 GetValue(0, 1) = sinVal; 00305 GetValue(1, 1) = cosVal; 00306 }
| unsigned short pcce::Matrix4::GetIndex | ( | const unsigned short & | i, | |
| const unsigned short & | j | |||
| ) | const [inline, private] |
Definition at line 168 of file Matrix4.h.
References ValuesPerRow.
Referenced by GetValue().
00168 { 00169 return j * ValuesPerRow + i; 00170 }
| const tReal& pcce::Matrix4::GetValue | ( | const unsigned short & | i, | |
| const unsigned short & | j | |||
| ) | const [inline, private] |
Definition at line 171 of file Matrix4.h.
References GetIndex(), and mValues.
Referenced by Concatenate(), GetTranspose(), Matrix4(), operator()(), operator*(), SetRotateX(), SetRotateY(), SetRotateZ(), SetScale(), SetTranslate(), and SetValues().
| tReal& pcce::Matrix4::GetValue | ( | const unsigned short & | i, | |
| const unsigned short & | j | |||
| ) | [inline, private] |
const unsigned short pcce::Matrix4::TotalValues = 16 [static, private] |
Definition at line 164 of file Matrix4.h.
Referenced by operator*(), operator+(), operator-(), and operator==().
const unsigned short pcce::Matrix4::ValuesPerRow = 4 [static, private] |
tReal pcce::Matrix4::mValues[TotalValues] [private] |
Definition at line 166 of file Matrix4.h.
Referenced by GetValue(), operator*(), operator+(), operator-(), and operator==().
1.5.5