Added Quaternion::(Make)RotationBetween
Former-commit-id: e28517580bd17970e77a38f54e7c114cdaf402d5
This commit is contained in:
parent
16004fd41c
commit
6c743a89b9
|
|
@ -37,6 +37,7 @@ template<typename T> class NzQuaternion
|
||||||
NzQuaternion& Inverse();
|
NzQuaternion& Inverse();
|
||||||
|
|
||||||
NzQuaternion& MakeIdentity();
|
NzQuaternion& MakeIdentity();
|
||||||
|
NzQuaternion& MakeRotationBetween(const NzVector3<T>& from, const NzVector3<T>& to);
|
||||||
NzQuaternion& MakeZero();
|
NzQuaternion& MakeZero();
|
||||||
|
|
||||||
T Magnitude() const;
|
T Magnitude() const;
|
||||||
|
|
@ -75,6 +76,7 @@ template<typename T> class NzQuaternion
|
||||||
|
|
||||||
static NzQuaternion Identity();
|
static NzQuaternion Identity();
|
||||||
static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
static NzQuaternion Lerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||||
|
static NzQuaternion RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to);
|
||||||
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
static NzQuaternion Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation);
|
||||||
static NzQuaternion Zero();
|
static NzQuaternion Zero();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,18 @@ NzQuaternion<T>& NzQuaternion<T>::MakeIdentity()
|
||||||
return Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
return Set(F(1.0), F(0.0), F(0.0), F(0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzQuaternion<T>& NzQuaternion<T>::MakeRotationBetween(const NzVector3<T>& from, const NzVector3<T>& to)
|
||||||
|
{
|
||||||
|
NzVector3f a = from.CrossProduct(to);
|
||||||
|
x = a.x;
|
||||||
|
y = a.y;
|
||||||
|
z = a.z;
|
||||||
|
w = std::sqrt(std::pow(from.GetLength(), 2.f) * std::pow(to.GetLength(), 2.f)) + from.DotProduct(to);
|
||||||
|
|
||||||
|
return Normalize();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzQuaternion<T>& NzQuaternion<T>::MakeZero()
|
NzQuaternion<T>& NzQuaternion<T>::MakeZero()
|
||||||
{
|
{
|
||||||
|
|
@ -382,6 +394,15 @@ NzQuaternion<T> NzQuaternion<T>::Lerp(const NzQuaternion& from, const NzQuaterni
|
||||||
return interpolated;
|
return interpolated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
NzQuaternion<T> NzQuaternion<T>::RotationBetween(const NzVector3<T>& from, const NzVector3<T>& to)
|
||||||
|
{
|
||||||
|
NzQuaternion quaternion;
|
||||||
|
quaternion.MakeRotationBetween(from, to);
|
||||||
|
|
||||||
|
return quaternion;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation)
|
NzQuaternion<T> NzQuaternion<T>::Slerp(const NzQuaternion& from, const NzQuaternion& to, T interpolation)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue