Added more implementations for Quaternions

This commit is contained in:
Diren D Bharwani 2022-09-08 22:46:51 +08:00
parent 01ff98b24f
commit 392b51898a
2 changed files with 62 additions and 5 deletions

View File

@ -212,14 +212,16 @@ namespace SHADE
SHQuaternion SHQuaternion::RotateTowards(const SHQuaternion&, float) const noexcept SHQuaternion SHQuaternion::RotateTowards(const SHQuaternion&, float) const noexcept
{ {
// TODO(Diren): Figure this out. SHQuaternion result;
return Identity; // TODO (Diren)
return result;
} }
SHVec3 SHQuaternion::ToEuler() const noexcept SHVec3 SHQuaternion::ToEuler() const noexcept
{ {
// TODO(Diren): Figure this out. // TODO (Diren)
return SHVec3::Zero; return SHVec3::Zero;
} }
@ -236,5 +238,60 @@ namespace SHADE
/* Static Function Member Definitions */ /* Static Function Member Definitions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
SHQuaternion SHQuaternion::Normalise(const SHQuaternion& q) noexcept
{
SHQuaternion result;
const XMVECTOR Q = XMLoadFloat4(&q);
XMStoreFloat4(&result, XMQuaternionNormalize(Q));
return result;
}
SHQuaternion SHQuaternion::Conjugate(const SHQuaternion& q) noexcept
{
SHQuaternion result;
const XMVECTOR Q = XMLoadFloat4(&q);
XMStoreFloat4(&result, XMQuaternionConjugate(Q));
return result;
}
float SHQuaternion::Angle(const SHQuaternion&, const SHQuaternion&) noexcept
{
// TODO (Diren)
return 0.0f;
}
SHQuaternion SHQuaternion::Lerp(const SHQuaternion&, const SHQuaternion&, float) noexcept
{
SHQuaternion result;
// TODO (Diren)
return result;
}
SHQuaternion SHQuaternion::Slerp(const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept
{
SHQuaternion result;
const XMVECTOR Q1 = XMLoadFloat4(&q1);
const XMVECTOR Q2 = XMLoadFloat4(&q2);
XMStoreFloat4(&result, XMQuaternionSlerp(Q1, Q2, t));
return result;
}
SHQuaternion SHQuaternion::Rotate(const SHVec3& , const SHVec3&) noexcept
{
SHQuaternion result;
// TODO (Diren)
return result;
}
} // namespace SHADE } // namespace SHADE

View File

@ -92,12 +92,12 @@ namespace SHADE
[[nodiscard]] static SHQuaternion Normalise (const SHQuaternion& q) noexcept; [[nodiscard]] static SHQuaternion Normalise (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Conjugate (const SHQuaternion& q) noexcept; [[nodiscard]] static SHQuaternion Conjugate (const SHQuaternion& q) noexcept;
[[nodiscard]] static SHQuaternion Angle (const SHQuaternion& q1, const SHQuaternion& q2) noexcept; [[nodiscard]] static SHQuaternion Inverse (const SHQuaternion& q) noexcept;
[[nodiscard]] static float Angle (const SHQuaternion& q1, const SHQuaternion& q2) noexcept;
[[nodiscard]] static SHQuaternion Lerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept; [[nodiscard]] static SHQuaternion Lerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Slerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept; [[nodiscard]] static SHQuaternion Slerp (const SHQuaternion& q1, const SHQuaternion& q2, float t) noexcept;
[[nodiscard]] static SHQuaternion Concat (const SHQuaternion& q1, const SHQuaternion& q2) noexcept;
[[nodiscard]] static SHQuaternion Rotate (const SHVec3& from, const SHVec3& to) noexcept; [[nodiscard]] static SHQuaternion Rotate (const SHVec3& from, const SHVec3& to) noexcept;
}; };