mirror of
https://github.com/orange-cpp/omath.git
synced 2026-04-30 06:23:27 +00:00
added more constexpr
This commit is contained in:
@@ -70,31 +70,31 @@ namespace omath
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Type sin() const noexcept
|
constexpr Type sin() const noexcept
|
||||||
{
|
{
|
||||||
return std::sin(as_radians());
|
return std::sin(as_radians());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Type cos() const noexcept
|
constexpr Type cos() const noexcept
|
||||||
{
|
{
|
||||||
return std::cos(as_radians());
|
return std::cos(as_radians());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Type tan() const noexcept
|
constexpr Type tan() const noexcept
|
||||||
{
|
{
|
||||||
return std::tan(as_radians());
|
return std::tan(as_radians());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Type atan() const noexcept
|
constexpr Type atan() const noexcept
|
||||||
{
|
{
|
||||||
return std::atan(as_radians());
|
return std::atan(as_radians());
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Type cot() const noexcept
|
constexpr Type cot() const noexcept
|
||||||
{
|
{
|
||||||
return cos() / sin();
|
return cos() / sin();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace omath::angles
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
requires std::is_floating_point_v<Type>
|
requires std::is_floating_point_v<Type>
|
||||||
[[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect) noexcept
|
[[nodiscard]] constexpr Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect) noexcept
|
||||||
{
|
{
|
||||||
const auto fov_rad = degrees_to_radians(horizontal_fov);
|
const auto fov_rad = degrees_to_radians(horizontal_fov);
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace omath::angles
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
requires std::is_floating_point_v<Type>
|
requires std::is_floating_point_v<Type>
|
||||||
[[nodiscard]] Type vertical_fov_to_horizontal(const Type& vertical_fov, const Type& aspect) noexcept
|
[[nodiscard]] constexpr Type vertical_fov_to_horizontal(const Type& vertical_fov, const Type& aspect) noexcept
|
||||||
{
|
{
|
||||||
const auto fov_as_radians = degrees_to_radians(vertical_fov);
|
const auto fov_as_radians = degrees_to_radians(vertical_fov);
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ namespace omath::angles
|
|||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
requires std::is_arithmetic_v<Type>
|
requires std::is_arithmetic_v<Type>
|
||||||
[[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max) noexcept
|
[[nodiscard]] constexpr Type wrap_angle(const Type& angle, const Type& min, const Type& max) noexcept
|
||||||
{
|
{
|
||||||
if (angle <= max && angle >= min)
|
if (angle <= max && angle >= min)
|
||||||
return angle;
|
return angle;
|
||||||
|
|||||||
Reference in New Issue
Block a user