added func

added rotation matrix for opengl
This commit is contained in:
2025-04-16 13:33:08 +03:00
parent 2180f8ab97
commit 1601f3cbc8
6 changed files with 30 additions and 11 deletions

View File

@@ -3,9 +3,9 @@
//
#pragma once
#include "omath/angles.hpp"
#include <algorithm>
#include <utility>
#include "omath/angles.hpp"
namespace omath
@@ -17,7 +17,7 @@ namespace omath
};
template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized>
requires std::is_arithmetic_v<Type>
requires std::is_arithmetic_v<Type>
class Angle
{
Type m_angle;
@@ -34,6 +34,7 @@ namespace omath
std::unreachable();
}
}
public:
[[nodiscard]]
constexpr static Angle FromDegrees(const Type& degrees)
@@ -42,7 +43,6 @@ namespace omath
}
constexpr Angle() : m_angle(0)
{
}
[[nodiscard]]
constexpr static Angle FromRadians(const Type& degrees)
@@ -149,4 +149,4 @@ namespace omath
return Angle{-m_angle};
}
};
}
} // namespace omath

View File

@@ -18,6 +18,8 @@ namespace omath::opengl_engine
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
[[nodiscard]]
Mat4x4 RotationMatrix(const ViewAngles& angles);
[[nodiscard]]
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);

View File

@@ -9,6 +9,10 @@ namespace omath::source_engine
[[nodiscard]]
Vector3<float> ForwardVector(const ViewAngles& angles);
[[nodiscard]]
Mat4x4 RotationMatrix(const ViewAngles& angles);
[[nodiscard]]
Vector3<float> RightVector(const ViewAngles& angles);
@@ -20,4 +24,6 @@ namespace omath::source_engine
[[nodiscard]]
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
} // namespace omath::source