File indexing completed on 2025-01-18 10:03:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _gp_TrsfNLerp_HeaderFile
0015 #define _gp_TrsfNLerp_HeaderFile
0016
0017 #include <gp_Trsf.hxx>
0018 #include <gp_QuaternionNLerp.hxx>
0019 #include <NCollection_Lerp.hxx>
0020 #include <Precision.hxx>
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 template<> class NCollection_Lerp<gp_Trsf>
0032 {
0033 public:
0034
0035
0036 NCollection_Lerp() {}
0037
0038
0039 NCollection_Lerp (const gp_Trsf& theStart, const gp_Trsf& theEnd)
0040 {
0041 Init (theStart, theEnd);
0042 }
0043
0044
0045 void Init (const gp_Trsf& theStart, const gp_Trsf& theEnd)
0046 {
0047 myTrsfStart = theStart;
0048 myTrsfEnd = theEnd;
0049 myLocLerp .Init (theStart.TranslationPart(), theEnd.TranslationPart());
0050 myRotLerp .Init (theStart.GetRotation(), theEnd.GetRotation());
0051 myScaleLerp.Init (theStart.ScaleFactor(), theEnd.ScaleFactor());
0052 }
0053
0054
0055
0056
0057
0058 void Interpolate (double theT, gp_Trsf& theResult) const
0059 {
0060 if (Abs (theT - 0.0) < Precision::Confusion())
0061 {
0062 theResult = myTrsfStart;
0063 return;
0064 }
0065 else if (Abs (theT - 1.0) < Precision::Confusion())
0066 {
0067 theResult = myTrsfEnd;
0068 return;
0069 }
0070
0071 gp_XYZ aLoc;
0072 gp_Quaternion aRot;
0073 Standard_Real aScale = 1.0;
0074 myLocLerp .Interpolate (theT, aLoc);
0075 myRotLerp .Interpolate (theT, aRot);
0076 myScaleLerp.Interpolate (theT, aScale);
0077 theResult = gp_Trsf();
0078 theResult.SetRotation (aRot);
0079 theResult.SetTranslationPart (aLoc);
0080 theResult.SetScaleFactor (aScale);
0081 }
0082
0083 private:
0084 NCollection_Lerp<gp_XYZ> myLocLerp;
0085 NCollection_Lerp<Standard_Real> myScaleLerp;
0086 gp_QuaternionNLerp myRotLerp;
0087 gp_Trsf myTrsfStart;
0088 gp_Trsf myTrsfEnd;
0089 };
0090
0091 typedef NCollection_Lerp<gp_Trsf> gp_TrsfNLerp;
0092
0093 #endif