53 FXQuatf(
const FXfloat v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){}
58 FXQuatf(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww):x(xx),y(yy),z(zz),w(ww){}
73 FXQuatf(FXfloat roll,FXfloat pitch,FXfloat yaw);
94 const FXfloat&
operator[](FXint i)
const {
return (&x)[i];}
114 FXQuatf&
set(
const FXfloat v[]){x=v[0];y=v[1];z=v[2];w=v[3];
return *
this;}
119 FXQuatf&
set(FXfloat xx,FXfloat yy,FXfloat zz,FXfloat ww){x=xx;y=yy;z=zz;w=ww;
return *
this;}
123 FXQuatf& operator/=(FXfloat n){
return set(x/n,y/n,z/n,w/n); }
124 FXQuatf& operator+=(
const FXQuatf& v){
return set(x+v.x,y+v.y,z+v.z,w+v.w); }
125 FXQuatf& operator-=(
const FXQuatf& v){
return set(x-v.x,y-v.y,z-v.z,w-v.w); }
126 FXQuatf& operator*=(
const FXQuatf& b){
return set(w*b.x+x*b.w+y*b.z-z*b.y, w*b.y+y*b.w+z*b.x-x*b.z, w*b.z+z*b.w+x*b.y-y*b.x, w*b.w-x*b.x-y*b.y-z*b.z); }
127 FXQuatf& operator/=(
const FXQuatf& b){
return *
this*=b.
invert(); }
130 operator FXfloat*(){
return &x;}
131 operator const FXfloat*()
const {
return &x;}
135 operator const FXVec3f&()
const {
return *
reinterpret_cast<const FXVec3f*
>(
this);}
138 FXbool
operator!()
const {
return x==0.0f && y==0.0f && z==0.0f && w==0.0f; }
145 FXfloat
length2()
const {
return w*w+z*z+y*y+x*x; }
146 FXfloat length()
const {
return Math::sqrt(length2()); }
155 void setAxisAngle(
const FXVec3f& axis,FXfloat phi);
162 void getAxisAngle(FXVec3f& axis,FXfloat& phi)
const;
169 void setRotation(
const FXVec3f& rot);
175 FXVec3f getRotation()
const;
182 void setMRP(
const FXVec3f& m);
187 FXVec3f getMRP()
const;
190 void setRollPitchYaw(FXfloat roll,FXfloat pitch,FXfloat yaw);
193 void getRollPitchYaw(FXfloat& roll,FXfloat& pitch,FXfloat& yaw)
const;
196 void setYawPitchRoll(FXfloat yaw,FXfloat pitch,FXfloat roll);
199 void getYawPitchRoll(FXfloat& yaw,FXfloat& pitch,FXfloat& roll)
const;
202 void setRollYawPitch(FXfloat roll,FXfloat yaw,FXfloat pitch);
205 void getRollYawPitch(FXfloat& roll,FXfloat& yaw,FXfloat& pitch)
const;
208 void setPitchRollYaw(FXfloat pitch,FXfloat roll,FXfloat yaw);
211 void getPitchRollYaw(FXfloat& pitch,FXfloat& roll,FXfloat& yaw)
const;
214 void setPitchYawRoll(FXfloat pitch,FXfloat yaw,FXfloat roll);
217 void getPitchYawRoll(FXfloat& pitch,FXfloat& yaw,FXfloat& roll)
const;
220 void setYawRollPitch(FXfloat yaw,FXfloat roll,FXfloat pitch);
223 void getYawRollPitch(FXfloat& yaw,FXfloat& roll,FXfloat& pitch)
const;
226 void setAxes(
const FXVec3f& ex,
const FXVec3f& ey,
const FXVec3f& ez);
229 void getAxes(FXVec3f& ex,FXVec3f& ey,FXVec3f& ez)
const;
232 FXVec3f getXAxis()
const;
235 FXVec3f getYAxis()
const;
238 FXVec3f getZAxis()
const;
247 FXQuatf pow(FXfloat t)
const;
264 static inline FXQuatf operator*(
const FXQuatf& a,FXfloat n){
return FXQuatf(a.x*n,a.y*n,a.z*n,a.w*n);}
265 static inline FXQuatf operator*(FXfloat n,
const FXQuatf& a){
return FXQuatf(n*a.x,n*a.y,n*a.z,n*a.w);}
266 static inline FXQuatf operator/(
const FXQuatf& a,FXfloat n){
return FXQuatf(a.x/n,a.y/n,a.z/n,a.w/n);}
267 static inline FXQuatf operator/(FXfloat n,
const FXQuatf& a){
return FXQuatf(n/a.x,n/a.y,n/a.z,n/a.w);}
270 static inline FXQuatf operator*(
const FXQuatf& a,
const FXQuatf& b){
return FXQuatf(a.w*b.x+a.x*b.w+a.y*b.z-a.z*b.y, a.w*b.y+a.y*b.w+a.z*b.x-a.x*b.z, a.w*b.z+a.z*b.w+a.x*b.y-a.y*b.x, a.w*b.w-a.x*b.x-a.y*b.y-a.z*b.z); }
271 static inline FXQuatf operator/(
const FXQuatf& a,
const FXQuatf& b){
return a*b.
invert(); }
274 extern FXAPI FXVec3f operator*(
const FXQuatf& q,
const FXVec3f& v);
277 extern FXAPI FXVec3f operator*(
const FXVec3f& v,
const FXQuatf& q);
280 static inline FXQuatf operator+(
const FXQuatf& a,
const FXQuatf& b){
return FXQuatf(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); }
281 static inline FXQuatf operator-(
const FXQuatf& a,
const FXQuatf& b){
return FXQuatf(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); }
284 static inline FXbool operator==(
const FXQuatf& a,FXfloat n){
return a.x==n && a.y==n && a.z==n && a.w==n;}
285 static inline FXbool operator!=(
const FXQuatf& a,FXfloat n){
return a.x!=n || a.y!=n || a.z!=n || a.w!=n;}
286 static inline FXbool operator==(FXfloat n,
const FXQuatf& a){
return n==a.x && n==a.y && n==a.z && n==a.w;}
287 static inline FXbool operator!=(FXfloat n,
const FXQuatf& a){
return n!=a.x || n!=a.y || n!=a.z || n!=a.w;}
290 static inline FXbool operator==(
const FXQuatf& a,
const FXQuatf& b){
return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; }
291 static inline FXbool operator!=(
const FXQuatf& a,
const FXQuatf& b){
return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; }
294 static inline FXQuatf normalize(
const FXQuatf& q){
return q*Math::rsqrt(q.length2()); }
297 static inline FXQuatf fastnormalize(
const FXQuatf& q){
return q*((3.0f-q.length2())*0.5f); }
301 extern FXAPI FXQuatf arc(
const FXVec3f& a,
const FXVec3f& b);
304 extern FXAPI FXQuatf lerp(
const FXQuatf& u,
const FXQuatf& v,FXfloat f);
307 extern FXAPI FXQuatf lerpdot(
const FXQuatf& u,
const FXQuatf& v,FXfloat f);
312 extern FXAPI FXQuatf hermite(
const FXQuatf& q0,
const FXVec3f& r0,
const FXQuatf& q1,
const FXVec3f& r1,FXfloat t);
315 extern FXAPI FXVec3f omegaBody(
const FXQuatf& q0,
const FXQuatf& q1,FXfloat dt);
318 extern FXAPI FXQuatf quatDot(
const FXQuatf& q,
const FXVec3f& omega);
322 extern FXAPI FXVec3f omegaDot(
const FXMat3f& M,
const FXVec3f& omega,
const FXVec3f& torq);
325 extern FXAPI FXStream& operator<<(FXStream& store,
const FXQuatf& v);
328 extern FXAPI FXStream& operator>>(FXStream& store,FXQuatf& v);
~FXQuatf()
Destructor.
Definition: FXQuatf.h:259
FXfloat length2() const
Length and square of length.
Definition: FXQuatf.h:145
FXQuatf(const FXfloat v[])
Construct from array of four floats.
Definition: FXQuatf.h:53
const FXfloat & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXQuatf.h:94
FXQuatf()
Default constructor; value is not initialized.
Definition: FXQuatf.h:43
FXQuatf & operator=(const FXfloat v[])
Assignment from array of four floats.
Definition: FXQuatf.h:104
FXbool operator!() const
Test if zero.
Definition: FXQuatf.h:138
FXQuatf(FXfloat xx, FXfloat yy, FXfloat zz, FXfloat ww)
Construct from four components.
Definition: FXQuatf.h:58
FXQuatf & operator*=(FXfloat n)
Assigning operators.
Definition: FXQuatf.h:122
FXQuatf unitinvert() const
Invert unit quaternion.
Definition: FXQuatf.h:253
FXQuatf conj() const
Conjugate quaternion.
Definition: FXQuatf.h:250
Definition: FX4Splitter.h:28
FXfloat & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXQuatf.h:89
FXQuatf invert() const
Invert quaternion.
Definition: FXQuatf.h:256
Single-precision quaternion.
Definition: FXQuatf.h:32
Single-precision 3-element vector.
Definition: FXVec3f.h:28
FXQuatf & operator=(const FXQuatf &v)
Assignment from other quaternion.
Definition: FXQuatf.h:99
FXQuatf operator+() const
Unary.
Definition: FXQuatf.h:141
FXMat2d invert() const
Invert.
FXQuatf(const FXQuatf &q)
Copy constructor.
Definition: FXQuatf.h:48