mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-12 22:53:27 +00:00
added for other engines
This commit is contained in:
@@ -23,4 +23,52 @@ namespace omath::frostbite_engine
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
||||
} // namespace omath::unity_engine
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_centimeters(const FloatingType& units)
|
||||
{
|
||||
return units / static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_meters(const FloatingType& units)
|
||||
{
|
||||
return units;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_kilometers(const FloatingType& units)
|
||||
{
|
||||
return units_to_meters(units) / static_cast<FloatingType>(1000);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType centimeters_to_units(const FloatingType& centimeters)
|
||||
{
|
||||
return centimeters * static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType meters_to_units(const FloatingType& meters)
|
||||
{
|
||||
return meters;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType kilometers_to_units(const FloatingType& kilometers)
|
||||
{
|
||||
return meters_to_units(kilometers * static_cast<FloatingType>(1000));
|
||||
}
|
||||
} // namespace omath::frostbite_engine
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#pragma once
|
||||
#include "omath/engines/opengl_engine/constants.hpp"
|
||||
|
||||
|
||||
namespace omath::opengl_engine
|
||||
{
|
||||
[[nodiscard]]
|
||||
@@ -23,4 +22,52 @@ namespace omath::opengl_engine
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_centimeters(const FloatingType& units)
|
||||
{
|
||||
return units / static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_meters(const FloatingType& units)
|
||||
{
|
||||
return units;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_kilometers(const FloatingType& units)
|
||||
{
|
||||
return units_to_meters(units) / static_cast<FloatingType>(1000);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType centimeters_to_units(const FloatingType& centimeters)
|
||||
{
|
||||
return centimeters * static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType meters_to_units(const FloatingType& meters)
|
||||
{
|
||||
return meters;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType kilometers_to_units(const FloatingType& kilometers)
|
||||
{
|
||||
return meters_to_units(kilometers * static_cast<FloatingType>(1000));
|
||||
}
|
||||
} // namespace omath::opengl_engine
|
||||
|
||||
@@ -23,4 +23,52 @@ namespace omath::unity_engine
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_centimeters(const FloatingType& units)
|
||||
{
|
||||
return units / static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_meters(const FloatingType& units)
|
||||
{
|
||||
return units;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_kilometers(const FloatingType& units)
|
||||
{
|
||||
return units_to_meters(units) / static_cast<FloatingType>(1000);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType centimeters_to_units(const FloatingType& centimeters)
|
||||
{
|
||||
return centimeters * static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType meters_to_units(const FloatingType& meters)
|
||||
{
|
||||
return meters;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType kilometers_to_units(const FloatingType& kilometers)
|
||||
{
|
||||
return meters_to_units(kilometers * static_cast<FloatingType>(1000));
|
||||
}
|
||||
} // namespace omath::unity_engine
|
||||
|
||||
@@ -23,4 +23,52 @@ namespace omath::unreal_engine
|
||||
|
||||
[[nodiscard]]
|
||||
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_centimeters(const FloatingType& units)
|
||||
{
|
||||
return units;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_meters(const FloatingType& units)
|
||||
{
|
||||
return units / static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType units_to_kilometers(const FloatingType& units)
|
||||
{
|
||||
return units_to_meters(units) / static_cast<FloatingType>(1000);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType centimeters_to_units(const FloatingType& centimeters)
|
||||
{
|
||||
return centimeters;
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType meters_to_units(const FloatingType& meters)
|
||||
{
|
||||
return meters * static_cast<FloatingType>(100);
|
||||
}
|
||||
|
||||
template<class FloatingType>
|
||||
requires std::is_floating_point_v<FloatingType>
|
||||
[[nodiscard]]
|
||||
constexpr FloatingType kilometers_to_units(const FloatingType& kilometers)
|
||||
{
|
||||
return meters_to_units(kilometers * static_cast<FloatingType>(1000));
|
||||
}
|
||||
} // namespace omath::unreal_engine
|
||||
|
||||
Reference in New Issue
Block a user