123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- #pragma once
- #include <Mathematics/Quaternion.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class SLERP
- {
- public:
-
-
- template <int N>
- inline static Quaternion<Real> Estimate(Real t, Quaternion<Real> const& q0, Quaternion<Real> const& q1)
- {
- static_assert(1 <= N && N <= 16, "Invalid degree.");
- Real cs = Dot(q0, q1);
- Real sign;
- if (cs >= (Real)0)
- {
- sign = (Real)1;
- }
- else
- {
- cs = -cs;
- sign = (Real)-1;
- }
- Real f0, f1;
- ChebyshevRatio<Real>::template GetEstimate<N>(t, (Real)1 - cs, f0, f1);
- return q0 * f0 + q1 * (sign * f1);
- }
-
-
-
-
-
-
-
-
-
-
-
- template <int N>
- inline static Quaternion<Real> EstimateR(Real t, Quaternion<Real> const& q0, Quaternion<Real> const& q1)
- {
- static_assert(1 <= N && N <= 16, "Invalid degree.");
- Real f0, f1;
- ChebyshevRatio<Real>::template GetEstimate<N>(t, (Real)1 - Dot(q0, q1), f0, f1);
- return q0 * f0 + q1 * f1;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <int N>
- inline static Quaternion<Real> EstimateRP(Real t, Quaternion<Real> const& q0, Quaternion<Real> const& q1,
- Real omcosA)
- {
- static_assert(1 <= N && N <= 16, "Invalid degree.");
- Real f0, f1;
- ChebyshevRatio<Real>::template GetEstimate<N>(t, omcosA, f0, f1);
- return q0 * f0 + q1 * f1;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <int N>
- inline static Quaternion<Real> EstimateRPH(Real t, Quaternion<Real> const& q0, Quaternion<Real> const& q1,
- Quaternion<Real> const& qh, Real omcosAH)
- {
- static_assert(1 <= N && N <= 16, "Invalid degree.");
- Real f0, f1;
- Real twoT = t * (Real)2;
- if (twoT <= (Real)1)
- {
- ChebyshevRatio<Real>::template GetEstimate<N>(twoT, omcosAH, f0, f1);
- return q0 * f0 + qh * f1;
- }
- else
- {
- ChebyshevRatio<Real>::template GetEstimate<N>(twoT - (Real)1, omcosAH, f0, f1);
- return qh * f0 + q1 * f1;
- }
- }
- };
- }
|