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
00127 class SbRotation {
00128 public:
00129
00133 SbRotation()
00134 { setValue(0.0f, 0.0f, 0.0f, 1.0f);}
00135
00141 SbRotation(const float v[4])
00142 { setValue(v); }
00143
00149 SbRotation(float q0, float q1, float q2, float q3)
00150 { setValue(q0, q1, q2, q3); }
00151
00156 SbRotation(const SbMatrix &m)
00157 { setValue(m); }
00158
00163 SbRotation(const SbMatrix3 &m)
00164 { setValue(m); }
00165
00170 SbRotation(const SbVec3f &axis, float radians)
00171 { setValue(axis, radians); }
00172
00179 SbRotation(const SbVec3f &rotateFrom, const SbVec3f &rotateTo)
00180 { setValue(rotateFrom, rotateTo); }
00181
00185 const float * getValue() const
00186 { return (quat); }
00187
00192 void getValue(float &q0, float &q1,
00193 float &q2, float &q3) const;
00194
00199 void getValue(SbVec3f &axis, float &radians) const;
00200
00205 void getValue(SbMatrix &matrix) const;
00206
00211 void getValue(SbMatrix3 &matrix) const;
00212
00217 void getValue(SbMatrixd &matrix) const;
00218
00222 SbRotation &invert();
00223
00227 SbRotation inverse() const
00228 { SbRotation q = *this; return q.invert(); }
00229
00233 SbRotation &setValue(const float q[4]);
00234
00238 SbRotation &setValue(float q0, float q1, float q2, float q3);
00239
00243 SbRotation &setValue(const SbMatrix &m);
00244
00248 SbRotation &setValue(const SbMatrix3 &m) ;
00249
00253 SbRotation &setValue(const SbVec3f &axis, float radians);
00254
00259 SbRotation &setValue(const SbVec3f &rotateFrom,
00260 const SbVec3f &rotateTo);
00261
00265 SbRotation &setValue(const SbRotationd &rotated) ;
00266
00270 SbRotation &setValue(const SbMatrixd &md) ;
00271
00275 SbRotation & operator *=(const SbRotation &q);
00276
00280 friend int operator ==(const SbRotation &q1, const SbRotation &q2);
00284 friend int operator !=(const SbRotation &q1, const SbRotation &q2)
00285 { return !(q1 == q2); }
00286
00291 SbBool equals(const SbRotation &r, float tolerance) const;
00292
00296 friend SbRotation operator *(const SbRotation &q1, const SbRotation &q2);
00297
00301 void multVec(const SbVec3f &src, SbVec3f &dst) const;
00302
00307 void scaleAngle( float scaleFactor );
00308
00313 static SbRotation slerp(const SbRotation &rot0,
00314 const SbRotation &rot1, float t);
00315
00319 static SbRotation identity()
00320 { return SbRotation(0.0f, 0.0f, 0.0f, 1.0f); }
00321
00322 private:
00323 mutable float quat[4];
00324
00325
00326 float norm() const;
00327
00328
00329 void normalize() const;
00330
00331 };
00332
00334
00335
00336
00337
00338
00339
00341
00427 class SbRotationd {
00428 public:
00429
00433 SbRotationd()
00434 { setValue(0.0, 0.0, 0.0, 1.0); }
00435
00441 SbRotationd(const double v[4])
00442 { setValue(v); }
00443
00449 SbRotationd(double q0, double q1, double q2, double q3)
00450 { setValue(q0, q1, q2, q3); }
00451
00456 SbRotationd(const SbMatrixd &m)
00457 { setValue(m); }
00458
00463 SbRotationd(const SbMatrix3 &m)
00464 { setValue(m); }
00465
00470 SbRotationd(const SbVec3d &axis, double radians)
00471 { setValue(axis, radians); }
00472
00479 SbRotationd(const SbVec3d &rotateFrom, const SbVec3d &rotateTo)
00480 { setValue(rotateFrom, rotateTo); }
00481
00485 const double *getValue() const
00486 { return (quat); }
00487
00492 void getValue(double &q0, double &q1,
00493 double &q2, double &q3) const;
00494
00499 void getValue(SbVec3d &axis, double &radians) const;
00500
00505 void getValue(SbMatrixd &matrix) const;
00506
00511 void getValue(SbMatrix &matrix) const;
00512
00517 void getValue(SbMatrix3 &matrix) const;
00518
00522 SbRotationd &invert();
00523
00527 SbRotationd inverse() const
00528 { SbRotationd q = *this; return q.invert(); }
00529
00533 SbRotationd &setValue(const double q[4]);
00534
00538 SbRotationd &setValue(double q0, double q1, double q2, double q3);
00539
00543 SbRotationd &setValue(const SbMatrixd &m);
00544
00548 SbRotationd &setValue(const SbVec3d &axis, double radians);
00549
00554 SbRotationd &setValue(const SbVec3d &rotateFrom,
00555 const SbVec3d &rotateTo);
00556
00560 SbRotationd &setValue(const SbRotation &rotate) ;
00561
00565 SbRotationd &setValue(const SbMatrix &m) ;
00566
00570 SbRotationd &setValue(const SbMatrix3 &m) ;
00571
00575 SbRotationd & operator *=(const SbRotationd &q);
00576
00580 friend int operator ==(const SbRotationd &q1, const SbRotationd &q2);
00584 friend int operator !=(const SbRotationd &q1, const SbRotationd &q2)
00585 { return !(q1 == q2); }
00586
00591 SbBool equals(const SbRotationd &r, double tolerance) const;
00592
00596 friend SbRotationd operator *(const SbRotationd &q1, const SbRotationd &q2);
00597
00601 void multVec(const SbVec3d &src, SbVec3d &dst) const;
00602
00607 void scaleAngle( double scaleFactor );
00608
00613 static SbRotationd slerp(const SbRotationd &rot0,
00614 const SbRotationd &rot1, double t);
00615
00619 static SbRotationd identity()
00620 { return SbRotationd(0.0, 0.0, 0.0, 1.0); }
00621
00622 private:
00623 double quat[4];
00624
00625
00626 double norm() const;
00627
00628
00629 void normalize();
00630
00631 };
00632
00633 #endif
00634
00635
00636