Radium Engine  1.5.20
Loading...
Searching...
No Matches
Interpolation.hpp
1#pragma once
2
3#include <Core/Types.hpp>
4
5namespace Ra {
6namespace Core {
7namespace Math {
8
11
17template <typename T>
18inline T linearInterpolate( const T& v0, const T& v1, const Scalar t ) {
19 return ( ( 1_ra - t ) * v0 ) + ( t * v1 );
20}
21
26template <>
27inline Core::Quaternion linearInterpolate<Core::Quaternion>( const Core::Quaternion& q0,
28 const Core::Quaternion& q1,
29 const Scalar t ) {
30 return q0.slerp( t, q1 );
31}
32
39template <>
40inline Core::Transform linearInterpolate<Core::Transform>( const Core::Transform& T0,
41 const Core::Transform& T1,
42 const Scalar t ) {
43 Ra::Core::Matrix3 T0R, T1R;
44 Ra::Core::Matrix3 T0S, T1S;
45 T0.computeRotationScaling( &T0R, &T0S );
46 T1.computeRotationScaling( &T1R, &T1S );
47
48 Ra::Core::Quaternion T0Rot = Ra::Core::Quaternion( T0R );
49 Ra::Core::Quaternion T1Rot = Ra::Core::Quaternion( T1R );
50 Ra::Core::Quaternion iR = T0Rot.slerp( t, T1Rot );
51 Ra::Core::Matrix3 iS = ( 1 - t ) * T0S + t * T1S;
52 Ra::Core::Vector3 iT = ( 1 - t ) * T0.translation() + t * T1.translation();
53
54 Core::Transform result;
55 result.fromPositionOrientationScale( iT, iR, iS.diagonal() );
56 return result;
57}
59
60} // namespace Math
61} // namespace Core
62} // namespace Ra
Core::Transform linearInterpolate< Core::Transform >(const Core::Transform &T0, const Core::Transform &T1, const Scalar t)
Core::Quaternion linearInterpolate< Core::Quaternion >(const Core::Quaternion &q0, const Core::Quaternion &q1, const Scalar t)
T linearInterpolate(const T &v0, const T &v1, const Scalar t)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3