40 #ifndef __MO_MATH_QUATERNION_H__
41 #define __MO_MATH_QUATERNION_H__
65 inline operator const Real* ()
const {
return m_afTuple; }
66 inline operator Real* () {
return m_afTuple; }
67 inline Real
operator[] (
int i)
const {
return m_afTuple[i]; }
69 inline Real
W ()
const {
return m_afTuple[0]; }
70 inline Real&
W () {
return m_afTuple[0]; }
71 inline Real
X ()
const {
return m_afTuple[1]; }
72 inline Real&
X () {
return m_afTuple[1]; }
73 inline Real
Y ()
const {
return m_afTuple[2]; }
74 inline Real&
Y () {
return m_afTuple[2]; }
75 inline Real
Z ()
const {
return m_afTuple[3]; }
76 inline Real&
Z () {
return m_afTuple[3]; }
81 m_afTuple[0] = rkQ.m_afTuple[0];
82 m_afTuple[1] = rkQ.m_afTuple[1];
83 m_afTuple[2] = rkQ.m_afTuple[2];
84 m_afTuple[3] = rkQ.m_afTuple[3];
100 for (
int i = 0; i < 4; i++) kSum.m_afTuple[i] = m_afTuple[i] + rkQ.m_afTuple[i];
106 for (
int i = 0; i < 4; i++) kDiff.m_afTuple[i] = m_afTuple[i] - rkQ.m_afTuple[i];
117 m_afTuple[0]*rkQ.m_afTuple[0] -
118 m_afTuple[1]*rkQ.m_afTuple[1] -
119 m_afTuple[2]*rkQ.m_afTuple[2] -
120 m_afTuple[3]*rkQ.m_afTuple[3];
123 m_afTuple[0]*rkQ.m_afTuple[1] +
124 m_afTuple[1]*rkQ.m_afTuple[0] +
125 m_afTuple[2]*rkQ.m_afTuple[3] -
126 m_afTuple[3]*rkQ.m_afTuple[2];
129 m_afTuple[0]*rkQ.m_afTuple[2] +
130 m_afTuple[2]*rkQ.m_afTuple[0] +
131 m_afTuple[3]*rkQ.m_afTuple[1] -
132 m_afTuple[1]*rkQ.m_afTuple[3];
135 m_afTuple[0]*rkQ.m_afTuple[3] +
136 m_afTuple[3]*rkQ.m_afTuple[0] +
137 m_afTuple[1]*rkQ.m_afTuple[2] -
138 m_afTuple[2]*rkQ.m_afTuple[1];
145 for (
int i = 0; i < 4; i++) kProd.m_afTuple[i] = fScalar*m_afTuple[i];
153 if (fScalar != (Real)0.0)
155 Real fInvScalar = ((Real)1.0)/fScalar;
156 for (i = 0; i < 4; i++) kQuot.m_afTuple[i] = fInvScalar*m_afTuple[i];
168 for (
int i = 0; i < 4; i++) kNeg.m_afTuple[i] = -m_afTuple[i];
175 for (
int i = 0; i < 4; i++) m_afTuple[i] += rkQ.m_afTuple[i];
180 for (
int i = 0; i < 4; i++) m_afTuple[i] -= rkQ.m_afTuple[i];
185 for (
int i = 0; i < 4; i++) m_afTuple[i] *= fScalar;
192 if (fScalar != (Real)0.0)
194 Real fInvScalar = ((Real)1.0)/fScalar;
195 for (i = 0; i < 4; i++) m_afTuple[i] *= fInvScalar;
199 for (i = 0; i < 4; i++) m_afTuple[i] = moMath<Real>::MAX_REAL;
206 moQuaternion& FromRotationMatrix (
const moMatrix3<Real>& rkRot);
207 void ToRotationMatrix (moMatrix3<Real>& rkRot)
const;
217 m_afTuple[0]*m_afTuple[0] +
218 m_afTuple[1]*m_afTuple[1] +
219 m_afTuple[2]*m_afTuple[2] +
220 m_afTuple[3]*m_afTuple[3]);
225 m_afTuple[0]*m_afTuple[0] +
226 m_afTuple[1]*m_afTuple[1] +
227 m_afTuple[2]*m_afTuple[2] +
228 m_afTuple[3]*m_afTuple[3];
232 Real fDot = (Real)0.0;
233 for (
int i = 0; i < 4; i++) fDot += m_afTuple[i]*rkQ.m_afTuple[i];
238 Real fLength = Length();
242 Real fInvLength = ((Real)1.0)/fLength;
243 m_afTuple[0] *= fInvLength;
244 m_afTuple[1] *= fInvLength;
245 m_afTuple[2] *= fInvLength;
246 m_afTuple[3] *= fInvLength;
251 m_afTuple[0] = (Real)0.0;
252 m_afTuple[1] = (Real)0.0;
253 m_afTuple[2] = (Real)0.0;
254 m_afTuple[3] = (Real)0.0;
313 static int ms_iNext[3];
318 template <
class Real>
322 for (
int i = 0; i < 4; i++)
324 kProd[i] = fScalar*rkQ[i];
moMatrix3< Real > & FromAxisAngle(const moVector3< Real > &rkAxis, Real fAngle)
bool operator<=(const moMatrix3 &rkM) const
static const moQuaternion IDENTITY
moMatrix3 operator-(const moMatrix3 &rkM) const
moMatrix3 operator/(Real fScalar) const
bool operator>(const moMatrix3 &rkM) const
void ToAxisAngle(moVector3< Real > &rkAxis, Real &rfAngle) const
moMatrix3< Real > Inverse() const
moQuaternion< MOfloat > moQuaternionf
Clase base abstracta de donde deben derivar los objetos [virtual pura].
moMatrix3 & operator-=(const moMatrix3 &rkM)
bool operator==(const moMatrix3 &rkM) const
static Real Sqrt(Real fValue)
bool operator<(const moMatrix3 &rkM) const
moMatrix3< Real > & Slerp(Real fT, const moMatrix3 &rkR0, const moMatrix3 &rkR1)
Real SquaredLength() const
moMatrix3 & operator/=(Real fScalar)
static const moQuaternion ZERO
bool operator!=(const moMatrix3 &rkM) const
moMatrix3 & operator*=(Real fScalar)
bool operator>=(const moMatrix3 &rkM) const
moMatrix3 & operator=(const moMatrix3 &rkM)
Real Dot(const moQuaternion &rkQ) const
moMatrix3 operator+(const moMatrix3 &rkM) const
moQuaternion< MOdouble > moQuaterniond
moMatrix3 & operator+=(const moMatrix3 &rkM)
const Real * operator[](int iRow) const
moQuaternion< Real > operator*(Real fScalar, const moQuaternion< Real > &rkQ)