File indexing completed on 2026-09-09 09:15:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _gp_QuaternionSLerp_HeaderFile
0015 #define _gp_QuaternionSLerp_HeaderFile
0016
0017 #include <gp_Quaternion.hxx>
0018
0019
0020
0021 class gp_QuaternionSLerp
0022 {
0023 public:
0024
0025
0026
0027
0028
0029 static gp_Quaternion Interpolate(const gp_Quaternion& theQStart,
0030 const gp_Quaternion& theQEnd,
0031 Standard_Real theT)
0032 {
0033 gp_Quaternion aResult;
0034 gp_QuaternionSLerp aLerp(theQStart, theQEnd);
0035 aLerp.Interpolate(theT, aResult);
0036 return aResult;
0037 }
0038
0039 public:
0040
0041 gp_QuaternionSLerp() {}
0042
0043
0044 gp_QuaternionSLerp(const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
0045 {
0046 Init(theQStart, theQEnd);
0047 }
0048
0049
0050 void Init(const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
0051 {
0052 InitFromUnit(theQStart.Normalized(), theQEnd.Normalized());
0053 }
0054
0055
0056 void InitFromUnit(const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
0057 {
0058 myQStart = theQStart;
0059 myQEnd = theQEnd;
0060 Standard_Real cosOmega = myQStart.Dot(myQEnd);
0061 if (cosOmega < 0.0)
0062 {
0063 cosOmega = -cosOmega;
0064 myQEnd = -myQEnd;
0065 }
0066 if (cosOmega > 0.9999)
0067 {
0068 cosOmega = 0.9999;
0069 }
0070 myOmega = ACos(cosOmega);
0071 Standard_Real invSinOmega = (1.0 / Sin(myOmega));
0072 myQStart.Scale(invSinOmega);
0073 myQEnd.Scale(invSinOmega);
0074 }
0075
0076
0077 void Interpolate(Standard_Real theT, gp_Quaternion& theResultQ) const
0078 {
0079 theResultQ = myQStart * Sin((1.0 - theT) * myOmega) + myQEnd * Sin(theT * myOmega);
0080 }
0081
0082 private:
0083 gp_Quaternion myQStart;
0084 gp_Quaternion myQEnd;
0085 Standard_Real myOmega;
0086 };
0087
0088 #endif