26 namespace OpenSkyNet {
29 Matrix3x3
operator*(
const Matrix3x3& lhs_,
const Matrix3x3& rhs_);
36 _columns[0][0] = 1.0f;
37 _columns[1][1] = 1.0f;
38 _columns[2][2] = 1.0f;
42 _columns[0] = localXAxis_;
43 _columns[1] = localYAxis_;
44 _columns[2] = localZAxis_;
65 col(0)[1] = -(tmp.
col(1)[0]*tmp.
col(2)[2] - tmp.
col(1)[2]*tmp.
col(2)[0]);
68 col(1)[0] = -(tmp.
col(0)[1]*tmp.
col(2)[2] - tmp.
col(0)[2]*tmp.
col(2)[1]);
70 col(1)[2] = -(tmp.
col(0)[0]*tmp.
col(2)[1] - tmp.
col(0)[1]*tmp.
col(2)[0]);
73 col(2)[1] = -(tmp.
col(0)[0]*tmp.
col(1)[2] - tmp.
col(0)[2]*tmp.
col(1)[0]);
78 float tmp =
col(0)[1];
117 result.
col(0) *= invDet;
118 result.
col(1) *= invDet;
119 result.
col(2) *= invDet;
131 float cosAngle = cosf(radians_);
132 float sinAngle = sinf(radians_);
133 float oneMinusCos = 1.0f - cosAngle;
135 rotMat.
col(0)[0] = cosAngle + oneMinusCos * axis_.
x() * axis_.
x();
136 rotMat.
col(0)[1] = oneMinusCos * axis_.
x() * axis_.
y() + axis_.
z() * sinAngle;
137 rotMat.
col(0)[2] = oneMinusCos * axis_.
x() * axis_.
z() - axis_.
y() * sinAngle;
139 rotMat.
col(1)[0] = oneMinusCos * axis_.
x() * axis_.
y() - axis_.
z() * sinAngle;
140 rotMat.
col(1)[1] = cosAngle + oneMinusCos * axis_.
y() * axis_.
y();
141 rotMat.
col(1)[2] = oneMinusCos * axis_.
y() * axis_.
z() + axis_.
x() * sinAngle;
143 rotMat.
col(2)[0] = oneMinusCos * axis_.
x() * axis_.
z() + axis_.
y() * sinAngle;
144 rotMat.
col(2)[1] = oneMinusCos * axis_.
y() * axis_.
z() - axis_.
x() * sinAngle;
145 rotMat.
col(2)[2] = cosAngle + oneMinusCos * axis_.
z() * axis_.
z();
167 assert(!((rot_.
col(0)[0] + 1.0f) / 2.0f < 0.0f));
168 assert(!((rot_.
col(1)[1] + 1.0f) / 2.0f < 0.0f));
169 assert(!((rot_.
col(2)[2] + 1.0f) / 2.0f < 0.0f));
171 axis_ =
Point<>(sqrt((rot_.
col(0)[0] + 1.0f) / 2.0f),
172 sqrt((rot_.
col(1)[1] + 1.0f) / 2.0f),
173 sqrt((rot_.
col(2)[2] + 1.0f) / 2.0f));
180 if (isXZero && !isYZero && !isZZero) {
181 if (!isYZPos) axis_.
y() = -axis_.y();
182 }
else if (isYZero && !isZZero) {
183 if (!isXZPos) axis_.z() = -axis_.z();
184 }
else if (isZZero) {
185 if (!isXYPos) axis_.x() = -axis_.x();
190 radians_ = acos((rot_.
col(0)[0] + rot_.
col(1)[1] + rot_.
col(2)[2] - 1.0f) / 2.0f);
192 (rot_.
col(2)[0] - rot_.
col(0)[2]),
193 (rot_.
col(0)[1] - rot_.
col(1)[0]));
201 result.
x() = lhs_.
x() * rhs_.
col(0)[0] + lhs_.
y() * rhs_.
col(1)[0] + lhs_.
z() * rhs_.
col(2)[0];
202 result.
y() = lhs_.
x() * rhs_.
col(0)[1] + lhs_.
y() * rhs_.
col(1)[1] + lhs_.
z() * rhs_.
col(2)[1];
203 result.
z() = lhs_.
x() * rhs_.
col(0)[2] + lhs_.
y() * rhs_.
col(1)[2] + lhs_.
z() * rhs_.
col(2)[2];
210 result.
col(0)[0] = rhs_.
col(0)[0]*lhs_.
col(0)[0] + rhs_.
col(1)[0]*lhs_.
col(0)[1] + rhs_.
col(2)[0]*lhs_.
col(0)[2];
211 result.
col(0)[1] = rhs_.
col(0)[1]*lhs_.
col(0)[0] + rhs_.
col(1)[1]*lhs_.
col(0)[1] + rhs_.
col(2)[1]*lhs_.
col(0)[2];
212 result.
col(0)[2] = rhs_.
col(0)[2]*lhs_.
col(0)[0] + rhs_.
col(1)[2]*lhs_.
col(0)[1] + rhs_.
col(2)[2]*lhs_.
col(0)[2];
214 result.
col(1)[0] = rhs_.
col(0)[0]*lhs_.
col(1)[0] + rhs_.
col(1)[0]*lhs_.
col(1)[1] + rhs_.
col(2)[0]*lhs_.
col(1)[2];
215 result.
col(1)[1] = rhs_.
col(0)[1]*lhs_.
col(1)[0] + rhs_.
col(1)[1]*lhs_.
col(1)[1] + rhs_.
col(2)[1]*lhs_.
col(1)[2];
216 result.
col(1)[2] = rhs_.
col(0)[2]*lhs_.
col(1)[0] + rhs_.
col(1)[2]*lhs_.
col(1)[1] + rhs_.
col(2)[2]*lhs_.
col(1)[2];
218 result.
col(2)[0] = rhs_.
col(0)[0]*lhs_.
col(2)[0] + rhs_.
col(1)[0]*lhs_.
col(2)[1] + rhs_.
col(2)[0]*lhs_.
col(2)[2];
219 result.
col(2)[1] = rhs_.
col(0)[1]*lhs_.
col(2)[0] + rhs_.
col(1)[1]*lhs_.
col(2)[1] + rhs_.
col(2)[1]*lhs_.
col(2)[2];
220 result.
col(2)[2] = rhs_.
col(0)[2]*lhs_.
col(2)[0] + rhs_.
col(1)[2]*lhs_.
col(2)[1] + rhs_.
col(2)[2]*lhs_.
col(2)[2];
227 #endif //MMATRIX3X3_H
Matrix3x3(const Math::Point<> &localXAxis_, const Math::Point<> &localYAxis_, const Math::Point<> &localZAxis_)
Definition: MMatrix3x3.h:41
Matrix3x3 operator*(const Matrix3x3 &lhs_, const Matrix3x3 &rhs_)
Definition: MMatrix3x3.h:208
void getAxisAngle(const Matrix3x3 &rot_, Math::Point<> &axis_, float &radians_)
Definition: MMatrix3x3.h:153
void normalize()
Definition: MPoint.h:139
T & y()
Definition: MPoint.h:65
const Matrix3x3 g_identityMatrix3x3
Definition: MMatrix3x3.cpp:5
T & x()
Definition: MPoint.h:64
void invert()
Definition: MMatrix3x3.h:102
void cofactor()
Definition: MMatrix3x3.h:62
Matrix3x3 getInverse() const
Definition: MMatrix3x3.h:112
void orthonormalize()
Definition: MMatrix3x3.h:92
T & z()
Definition: MPoint.h:66
void transpose()
Definition: MMatrix3x3.h:77
const Point g_xAxis(1.0f, 0.0f, 0.0f)
Definition: MPoint.h:215
Matrix3x3()
Definition: MMatrix3x3.h:35
const Math::Point & col(int i_) const
Definition: MMatrix3x3.h:50
Definition: MMatrix3x3.h:32
T getDot3(const Point< T > &rhs_) const
Definition: MPoint.h:202
Matrix3x3 getRotation(const Math::Point<> &axis_, float radians_)
Definition: MMatrix3x3.h:129
const float PI(3.14159265f)
const float CLOSE_TO_ZERO(0.00001f)
float float rot_[3]
Definition: ViewerApp.h:31
Math::Point & col(int i_)
Definition: MMatrix3x3.h:49
float getDeterminant() const
Definition: MMatrix3x3.h:53