00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SB_ROTATION_
00024 #define _SB_ROTATION_
00025
00026 #include <Inventor/SbVec.h>
00027
00028 class SbRotationd;
00029 class SbMatrix;
00030 class SbMatrix3;
00031 class SbMatrixd;
00032
00034
00035
00036
00037
00038
00039
00041
00042
00043
00126 class SbRotation {
00127 public:
00128
00132 SbRotation()
00133 { setValue(0.0f, 0.0f, 0.0f, 1.0f);}
00134
00140 SbRotation(const float v[4])
00141 { setValue(v); }
00142
00148 SbRotation(float q0, float q1, float q2, float q3)
00149 { setValue(q0, q1, q2, q3); }
00150
00155 SbRotation(const SbMatrix &m)
00156 { setValue(m); }
00157
00162 SbRotation(const SbMatrix3 &m)
00163 { setValue(m); }
00164
00169 SbRotation(const SbVec3f &axis, float radians)
00170 { setValue(axis, radians); }
00171
00178 SbRotation(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
00179 { setValue(rotateFrom, rotateTo); }
00180
00184 const float * getValue() const
00185 { return (quat); }
00186
00191 void getValue(float &q0, float &q1,
00192 float &q2, float &q3) const;
00193
00198 void getValue(SbVec3f &axis, float &radians) const;
00199
00204 void getValue(SbMatrix &matrix) const;
00205
00210 void getValue(SbMatrix3 &matrix) const;
00211
00216 void getValue(SbMatrixd &matrix) const;
00217
00221 SbRotation &invert();
00222
00226 SbRotation inverse() const
00227 { SbRotation q = *this; return q.invert(); }
00228
00232 SbRotation &setValue(const float q[4]);
00233
00237 SbRotation &setValue(float q0, float q1, float q2, float q3);
00238
00242 SbRotation &setValue(const SbMatrix &m);
00243
00247 SbRotation &setValue(const SbMatrix3 &m) ;
00248
00252 SbRotation &setValue(const SbVec3f &axis, float radians);
00253
00258 SbRotation &setValue(const SbVec3f &rotateFrom,
00259 const SbVec3f &rotateTo);
00260
00264 SbRotation &setValue(const SbRotationd &rotated) ;
00265
00269 SbRotation &setValue(const SbMatrixd &md) ;
00270
00274 SbRotation & operator *=(const SbRotation &q);
00275
00279 friend int operator ==(const SbRotation &q1, const SbRotation &q2);
00283 friend int operator !=(const SbRotation &q1, const SbRotation &q2)
00284 { return !(q1 == q2); }
00285
00290 SbBool equals(const SbRotation &r, float tolerance) const;
00291
00295 friend SbRotation operator *(const SbRotation &q1, const SbRotation &q2);
00296
00300 void multVec(const SbVec3f &src, SbVec3f &dst) const;
00301
00306 void scaleAngle( float scaleFactor );
00307
00312 static SbRotation slerp(const SbRotation &rot0,
00313 const SbRotation &rot1, float t);
00314
00318 static SbRotation identity()
00319 { return SbRotation(0.0f, 0.0f, 0.0f, 1.0f); }
00320
00321 private:
00322 mutable float quat[4];
00323
00324
00325 float norm() const;
00326
00327
00328 void normalize() const;
00329
00330 };
00331
00333
00334
00335
00336
00337
00338
00340
00425 class SbRotationd {
00426 public:
00427
00431 SbRotationd()
00432 { setValue(0.0, 0.0, 0.0, 1.0); }
00433
00439 SbRotationd(const double v[4])
00440 { setValue(v); }
00441
00447 SbRotationd(double q0, double q1, double q2, double q3)
00448 { setValue(q0, q1, q2, q3); }
00449
00454 SbRotationd(const SbMatrixd &m)
00455 { setValue(m); }
00456
00461 SbRotationd(const SbMatrix3 &m)
00462 { setValue(m); }
00463
00468 SbRotationd(const SbVec3d &axis, double radians)
00469 { setValue(axis, radians); }
00470
00477 SbRotationd(const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
00478 { setValue(rotateFrom, rotateTo); }
00479
00483 const double *getValue() const
00484 { return (quat); }
00485
00490 void getValue(double &q0, double &q1,
00491 double &q2, double &q3) const;
00492
00497 void getValue(SbVec3d &axis, double &radians) const;
00498
00503 void getValue(SbMatrixd &matrix) const;
00504
00509 void getValue(SbMatrix &matrix) const;
00510
00515 void getValue(SbMatrix3 &matrix) const;
00516
00520 SbRotationd &invert();
00521
00525 SbRotationd inverse() const
00526 { SbRotationd q = *this; return q.invert(); }
00527
00531 SbRotationd &setValue(const double q[4]);
00532
00536 SbRotationd &setValue(double q0, double q1, double q2, double q3);
00537
00541 SbRotationd &setValue(const SbMatrixd &m);
00542
00546 SbRotationd &setValue(const SbVec3d &axis, double radians);
00547
00552 SbRotationd &setValue(const SbVec3d &rotateFrom,
00553 const SbVec3d &rotateTo);
00554
00558 SbRotationd &setValue(const SbRotation &rotate) ;
00559
00563 SbRotationd &setValue(const SbMatrix &m) ;
00564
00568 SbRotationd &setValue(const SbMatrix3 &m) ;
00569
00573 SbRotationd & operator *=(const SbRotationd &q);
00574
00578 friend int operator ==(const SbRotationd &q1, const SbRotationd &q2);
00582 friend int operator !=(const SbRotationd &q1, const SbRotationd &q2)
00583 { return !(q1 == q2); }
00584
00589 SbBool equals(const SbRotationd &r, double tolerance) const;
00590
00594 friend SbRotationd operator *(const SbRotationd &q1, const SbRotationd &q2);
00595
00599 void multVec(const SbVec3d &src, SbVec3d &dst) const;
00600
00605 void scaleAngle( double scaleFactor );
00606
00611 static SbRotationd slerp(const SbRotationd &rot0,
00612 const SbRotationd &rot1, double t);
00613
00617 static SbRotationd identity()
00618 { return SbRotationd(0.0, 0.0, 0.0, 1.0); }
00619
00620 private:
00621 double quat[4];
00622
00623
00624 double norm() const;
00625
00626
00627 void normalize();
00628
00629 };
00630
00631 #endif
00632
00633
00634