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>
20 * Class perform linear interpolation (approximate rotation interpolation),
21 * result quaternion nonunit, its length lay between. sqrt(2)/2 and 1.0
23 class gp_QuaternionNLerp
28 gp_QuaternionNLerp() {}
30 gp_QuaternionNLerp (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
32 Init (theQStart, theQEnd);
35 void Init (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
37 InitFromUnit (theQStart.Normalized(), theQEnd.Normalized());
40 void InitFromUnit (const gp_Quaternion& theQStart, const gp_Quaternion& theQEnd)
44 Standard_Real anInner = myQStart.Dot (myQEnd);
52 //! Set interpolated quaternion for theT position (from 0.0 to 1.0)
53 void Interpolate (Standard_Real theT, gp_Quaternion& theResultQ) const
55 theResultQ = myQStart + myQEnd * theT;
58 static gp_Quaternion Interpolate (const gp_Quaternion& theQStart,
59 const gp_Quaternion& theQEnd,
62 gp_Quaternion aResultQ;
63 gp_QuaternionNLerp aNLerp (theQStart, theQEnd);
64 aNLerp.Interpolate (theT, aResultQ);
70 gp_Quaternion myQStart;
75 #endif //_gp_QuaternionNLerp_HeaderFile