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