1 #ifndef ossimQuaternion_HEADER 2 #define ossimQuaternion_HEADER 1 24 theVector[0]=0.0; theVector[1]=0.0; theVector[2]=0.0; theVector[3]=1.0;
53 makeRotate(angle,axis);
57 makeRotate(angle,axis);
93 if (theVector[0]<v.
theVector[0])
return true;
94 else if (theVector[0]>v.
theVector[0])
return false;
95 else if (theVector[1]<v.
theVector[1])
return true;
96 else if (theVector[1]>v.
theVector[1])
return false;
97 else if (theVector[2]<v.
theVector[2])
return true;
98 else if (theVector[2]>v.
theVector[2])
return false;
99 else return (theVector[3]<v.
theVector[3]);
116 inline value_type & operator [] (
int i) {
return theVector[i]; }
117 inline value_type operator [] (
int i)
const {
return theVector[i]; }
130 bool zeroRotation()
const {
return theVector[0]==0.0 && theVector[1]==0.0 && theVector[2]==0.0 && theVector[3]==1.0; }
143 return Quaternion(theVector[0]*rhs, theVector[1]*rhs, theVector[2]*rhs, theVector[3]*rhs);
184 return Quaternion(theVector[0]*div, theVector[1]*div, theVector[2]*div, theVector[3]*div);
201 return ( (*
this) * denom.
inverse() );
207 (*this) = (*this) * denom.
inverse();
249 return Quaternion (-theVector[0], -theVector[1], -theVector[2], -theVector[3]);
255 return std::sqrt( theVector[0]*theVector[0] + theVector[1]*theVector[1] + theVector[2]*theVector[2] + theVector[3]*theVector[3]);
261 return theVector[0]*theVector[0] + theVector[1]*theVector[1] + theVector[2]*theVector[2] + theVector[3]*theVector[3];
267 return Quaternion( -theVector[0], -theVector[1], -theVector[2], theVector[3] );
273 return conj() / length2();
286 void makeRotate( value_type angle,
287 value_type
x, value_type
y, value_type z );
289 { makeRotate(angle, vec[0], vec[1], vec[2]);}
291 { makeRotate(angle, vec.
x, vec.
y, vec.
z);}
296 void makeRotate ( value_type angle1,
const ossimDpt3d& axis1,
319 void getRotate ( value_type & angle, value_type &
x, value_type &
y, value_type & z )
const;
326 { getRotate(angle, vec.
x, vec.
y, vec.
z);}
337 ossimDpt3d qvec(theVector[0], theVector[1], theVector[2]);
340 uv *= ( 2.0f * theVector[3] );
353 return lhs + uv + uuv;
const Quaternion operator*(const Quaternion &rhs) const
Binary multiply.
Quaternion(value_type x, value_type y, value_type z, value_type w)
Quaternion(ossim_float64 angle, const ossimDpt3d &axis)
ossimRationalNumber operator-(ossim_int32 i, ossimRationalNumber &r)
value_type length() const
Length of the quaternion = sqrt( vec . vec )
const Quaternion operator/(const Quaternion &denom) const
Binary divide.
bool operator!=(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Quaternion & operator/=(const Quaternion &denom)
Unary divide.
This code was derived from https://gist.github.com/mshockwave.
ossimRationalNumber operator/(ossim_int32 i, ossimRationalNumber &r)
Quaternion conj() const
Conjugate.
bool zeroRotation() const
return true if the Quaternion represents a zero rotation, and therefore can be ignored in computation...
ossimRationalNumber operator*(ossim_int32 i, ossimRationalNumber &r)
void makeRotate(value_type angle, const ossimColumnVector3d &vec)
bool operator<(const BaseMatrix &A, const BaseMatrix &)
value_type length2() const
Length of the quaternion = vec . vec.
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Quaternion & operator*=(const Quaternion &rhs)
Unary multiply.
void getRotate(value_type &angle, ossimDpt3d &vec) const
Return the angle and vector components represented by the quaternion.
void makeRotate(value_type angle, const ossimDpt3d &vec)
ossimRationalNumber operator+(ossim_int32 i, ossimRationalNumber &r)
const Quaternion inverse() const
Multiplicative inverse method: q^(-1) = q^*/(q.q^*)
Quaternion(ossim_float64 angle, const ossimColumnVector3d &axis)