added rotation matrix

This commit is contained in:
2024-12-04 06:43:54 +03:00
parent db060e7f4d
commit 95c5073d86
2 changed files with 18 additions and 44 deletions

View File

@@ -349,19 +349,19 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]]
constexpr Mat<3, 3, Type, St> RotationMatrixAxisX(const Angle& roll) noexcept
Mat<3, 3, Type, St> RotationMatAxisX(const Angle& roll) noexcept
{
return
{
{1, 0, 0},
{0, 0, roll.Cos(), -roll.Sin()},
{0, 0, roll.Sin(), roll.Cos()},
{1, 0, 0},
{0, roll.Cos(), -roll.Sin()},
{0, roll.Sin(), roll.Cos()},
};
}
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]]
constexpr Mat<3, 3, Type, St> RotationMatrixAxisY(const Angle& pitch) noexcept
Mat<3, 3, Type, St> RotationMatAxisY(const Angle& pitch) noexcept
{
return
{
@@ -373,7 +373,7 @@ namespace omath
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class Angle>
[[nodiscard]]
constexpr Mat<3, 3, Type, St> RotationMatrixAxisZ(const Angle& Yaw) noexcept
Mat<3, 3, Type, St> RotationMatAxisZ(const Angle& Yaw) noexcept
{
return
{
@@ -383,5 +383,10 @@ namespace omath
};
}
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class ViewAngles>
[[nodiscard]]
Mat<3, 3, Type, St> RotationMat(const ViewAngles& angles) noexcept
{
return RotationMatAxisY(angles.pitch) * RotationMatAxisZ(angles.yaw) * RotationMatAxisX(angles.roll);
}
} // namespace omath