File indexing completed on 2026-09-16 09:17:18
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
0032 template <>
0033 class NCollection_Lerp<gp_Trsf>
0034 {
0035 public:
0036
0037 NCollection_Lerp() = default;
0038
0039
0040 NCollection_Lerp(const gp_Trsf& theStart, const gp_Trsf& theEnd) { Init(theStart, theEnd); }
0041
0042
0043 void Init(const gp_Trsf& theStart, const gp_Trsf& theEnd)
0044 {
0045 myTrsfStart = theStart;
0046 myTrsfEnd = theEnd;
0047 myLocLerp.Init(theStart.TranslationPart(), theEnd.TranslationPart());
0048 myRotLerp.Init(theStart.GetRotation(), theEnd.GetRotation());
0049 myScaleLerp.Init(theStart.ScaleFactor(), theEnd.ScaleFactor());
0050 }
0051
0052
0053
0054
0055
0056 void Interpolate(double theT, gp_Trsf& theResult) const
0057 {
0058 if (std::abs(theT - 0.0) < Precision::Confusion())
0059 {
0060 theResult = myTrsfStart;
0061 return;
0062 }
0063 else if (std::abs(theT - 1.0) < Precision::Confusion())
0064 {
0065 theResult = myTrsfEnd;
0066 return;
0067 }
0068
0069 gp_XYZ aLoc;
0070 gp_Quaternion aRot;
0071 double aScale = 1.0;
0072 myLocLerp.Interpolate(theT, aLoc);
0073 myRotLerp.Interpolate(theT, aRot);
0074 myScaleLerp.Interpolate(theT, aScale);
0075 theResult = gp_Trsf();
0076 theResult.SetRotation(aRot);
0077 theResult.SetTranslationPart(aLoc);
0078 theResult.SetScaleFactor(aScale);
0079 }
0080
0081 private:
0082 NCollection_Lerp<gp_XYZ> myLocLerp;
0083 NCollection_Lerp<double> myScaleLerp;
0084 gp_QuaternionNLerp myRotLerp;
0085 gp_Trsf myTrsfStart;
0086 gp_Trsf myTrsfEnd;
0087 };
0088
0089 #endif