1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _gp_QuaternionNLerp_HeaderFile
15 #define _gp_QuaternionNLerp_HeaderFile
17 #include <gp_Quaternion.hxx>
19 //! Class perform linear interpolation (approximate rotation interpolation),
20 //! result quaternion nonunit, its length lay between. sqrt(2)/2 and 1.0
21 class gp_QuaternionNLerp
25 //! Compute interpolated quaternion between two quaternions.
26 //! @param theStart first quaternion
27 //! @param theEnd second quaternion
28 //! @param theT normalized interpolation coefficient within 0..1 range,
29 //! with 0 pointing to theStart and 1 to theEnd.
30 static gp_Quaternion Interpolate (const gp_Quaternion& theQStart,
31 const gp_Quaternion& theQEnd,
34 gp_Quaternion aResult;
35 gp_QuaternionNLerp aLerp (theQStart, theQEnd);
36 aLerp.Interpolate (theT, aResult);
42 //! Empty constructor,
43 gp_QuaternionNLerp() {}
45 //! Constructor with initialization.
46 gp_QuaternionNLerp (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
48 Init (theQStart, theQEnd);
51 //! Initialize the tool with Start and End values.
52 void Init (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
54 InitFromUnit (theQStart.Normalized(), theQEnd.Normalized());
57 //! Initialize the tool with Start and End unit quaternions.
58 void InitFromUnit (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
62 Standard_Real anInner = myQStart.Dot (myQEnd);
70 //! Set interpolated quaternion for theT position (from 0.0 to 1.0)
71 void Interpolate (Standard_Real theT, gp_Quaternion& theResultQ) const
73 theResultQ = myQStart + myQEnd * theT;
78 gp_Quaternion myQStart;
83 #endif //_gp_QuaternionNLerp_HeaderFile