Added Forward & LookAt to C# Transforms #260

Merged
direnbharwani merged 2 commits from SP3-16-Math into main 2022-11-23 15:07:23 +08:00
2 changed files with 12 additions and 1 deletions
Showing only changes of commit 7202551838 - Show all commits

View File

@ -35,7 +35,7 @@ namespace SHADE
SHVec3 const SHVec3::Back { 0.0f, 0.0f, -1.0f }; SHVec3 const SHVec3::Back { 0.0f, 0.0f, -1.0f };
SHVec3 const SHVec3::UnitX { 1.0f, 0.0f, 0.0f }; SHVec3 const SHVec3::UnitX { 1.0f, 0.0f, 0.0f };
SHVec3 const SHVec3::UnitY { 0.0f, 1.0f, 0.0f }; SHVec3 const SHVec3::UnitY { 0.0f, 1.0f, 0.0f };
SHVec3 const SHVec3::UnitZ { 0.0f, 0.0f, 1.0f }; SHVec3 const SHVec3::UnitZ { 0.0f, 0.0f, -1.0f };
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Constructors & Destructor Definitions */ /* Constructors & Destructor Definitions */
@ -411,6 +411,14 @@ namespace SHADE
return result; return result;
} }
SHVec3 SHVec3::Rotate(const SHVec3& v, const SHQuaternion& q) noexcept
{
SHVec3 result;
XMStoreFloat3(&result, XMVector3Rotate(v, q));
return result;
}
SHVec3 SHVec3::RotateX(const SHVec3& v, float angleInRad) noexcept SHVec3 SHVec3::RotateX(const SHVec3& v, float angleInRad) noexcept
{ {
SHVec3 result; SHVec3 result;

View File

@ -25,6 +25,8 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Forward Declarations */ /* Forward Declarations */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
class SHQuaternion;
class SHMatrix; class SHMatrix;
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -136,6 +138,7 @@ namespace SHADE
[[nodiscard]] static SHVec3 Project (const SHVec3& v, const SHVec3& u) noexcept; [[nodiscard]] static SHVec3 Project (const SHVec3& v, const SHVec3& u) noexcept;
[[nodiscard]] static SHVec3 Reflect (const SHVec3& v, const SHVec3& normal) noexcept; [[nodiscard]] static SHVec3 Reflect (const SHVec3& v, const SHVec3& normal) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHVec3& axis, float angleInRad) noexcept; [[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHVec3& axis, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 Rotate (const SHVec3& v, const SHQuaternion& q) noexcept;
[[nodiscard]] static SHVec3 RotateX (const SHVec3& v, float angleInRad) noexcept; [[nodiscard]] static SHVec3 RotateX (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateY (const SHVec3& v, float angleInRad) noexcept; [[nodiscard]] static SHVec3 RotateY (const SHVec3& v, float angleInRad) noexcept;
[[nodiscard]] static SHVec3 RotateZ (const SHVec3& v, float angleInRad) noexcept; [[nodiscard]] static SHVec3 RotateZ (const SHVec3& v, float angleInRad) noexcept;