Skip to content

Commit f79831b

Browse files
committed
adding OvMaths::FMatrix4::Rotation and OvMaths::FMatrix4::Rotate
1 parent f3b8c75 commit f79831b

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

Sources/Overload/OvMaths/include/OvMaths/FMatrix4.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@
1515
#include "OvMaths/API/export.h"
1616
#include "OvMaths/FVector3.h"
1717
#include "OvMaths/FVector4.h"
18+
#include "OvMaths/FQuaternion.h"
1819

1920
namespace OvMaths
2021
{
22+
23+
/**
24+
* Forward declaration due to circular reference
25+
*/
26+
struct FQuaternion;
27+
2128
/**
2229
* Mathematic representation of a 4x4 Matrix of floats
2330
*/
@@ -341,6 +348,19 @@ namespace OvMaths
341348
*/
342349
static FMatrix4 Scale(const FMatrix4& p_matrix, const FVector3& p_scale);
343350

351+
/**
352+
* Return rotation matrix from quaternion
353+
* @param p_quaternion
354+
*/
355+
static FMatrix4 Rotation(const FQuaternion& p_quaternion);
356+
357+
/**
358+
* Return rotate matrix in 3D on quaternion
359+
* @param p_matrix
360+
* @param p_quaternion
361+
*/
362+
static FMatrix4 Rotate(const FMatrix4& p_matrix, const FQuaternion& p_quaternion);
363+
344364
/**
345365
* Return perspective matrix
346366
* @param p_fov

Sources/Overload/OvMaths/include/OvMaths/FQuaternion.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
namespace OvMaths
1717
{
18+
/**
19+
* Forward declaration due to circular reference
20+
*/
21+
struct FMatrix4;
22+
1823
/**
1924
* Mathematic representation of a Quaternion with float precision
2025
*/

Sources/Overload/OvMaths/src/OvMaths/FMatrix4.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,16 @@ OvMaths::FMatrix4 OvMaths::FMatrix4::Scale(const FMatrix4& p_matrix, const FVect
442442
return p_matrix * Scaling(p_scale);
443443
}
444444

445+
OvMaths::FMatrix4 OvMaths::FMatrix4::Rotation(const FQuaternion& p_quaternion)
446+
{
447+
return OvMaths::FQuaternion::ToMatrix4(p_quaternion);
448+
}
449+
450+
OvMaths::FMatrix4 OvMaths::FMatrix4::Rotate(const FMatrix4& p_matrix, const FQuaternion& p_quaternion)
451+
{
452+
return p_matrix * Rotation(p_quaternion);
453+
}
454+
445455
OvMaths::FMatrix4 OvMaths::FMatrix4::CreatePerspective(const float p_fov, const float p_aspectRatio, const float p_zNear, const float p_zFar)
446456
{
447457
const float tangent = tanf(p_fov / 2.0f * PI / 180.0f);

0 commit comments

Comments
 (0)