mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fixed style
This commit is contained in:
@@ -12,23 +12,23 @@ namespace omath::angles
|
||||
requires std::is_floating_point_v<Type>
|
||||
[[nodiscard]] constexpr Type radians_to_degrees(const Type& radians)
|
||||
{
|
||||
return radians * (Type(180) / std::numbers::pi_v<Type>);
|
||||
return radians * (static_cast<Type>(180) / std::numbers::pi_v<Type>);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
requires std::is_floating_point_v<Type>
|
||||
[[nodiscard]] constexpr Type degrees_to_radians(const Type& degrees)
|
||||
{
|
||||
return degrees * (std::numbers::pi_v<Type> / Type(180));
|
||||
return degrees * (std::numbers::pi_v<Type> / static_cast<Type>(180));
|
||||
}
|
||||
|
||||
template<class type>
|
||||
requires std::is_floating_point_v<type>
|
||||
[[nodiscard]] type horizontal_fov_to_vertical(const type& horizontal_fov, const type& aspect)
|
||||
template<class Type>
|
||||
requires std::is_floating_point_v<Type>
|
||||
[[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect)
|
||||
{
|
||||
const auto fov_rad = degrees_to_radians(horizontal_fov);
|
||||
|
||||
const auto vert_fov = type(2) * std::atan(std::tan(fov_rad / type(2)) / aspect);
|
||||
const auto vert_fov = static_cast<Type>(2) * std::atan(std::tan(fov_rad / static_cast<Type>(2)) / aspect);
|
||||
|
||||
return radians_to_degrees(vert_fov);
|
||||
}
|
||||
@@ -39,7 +39,8 @@ namespace omath::angles
|
||||
{
|
||||
const auto fov_as_radians = degrees_to_radians(vertical_fov);
|
||||
|
||||
const auto horizontal_fov = Type(2) * std::atan(std::tan(fov_as_radians / Type(2)) * aspect);
|
||||
const auto horizontal_fov
|
||||
= static_cast<Type>(2) * std::atan(std::tan(fov_as_radians / static_cast<Type>(2)) * aspect);
|
||||
|
||||
return radians_to_degrees(horizontal_fov);
|
||||
}
|
||||
@@ -53,11 +54,11 @@ namespace omath::angles
|
||||
|
||||
const Type range = max - min;
|
||||
|
||||
Type wrappedAngle = std::fmod(angle - min, range);
|
||||
Type wrapped_angle = std::fmod(angle - min, range);
|
||||
|
||||
if (wrappedAngle < 0)
|
||||
wrappedAngle += range;
|
||||
if (wrapped_angle < 0)
|
||||
wrapped_angle += range;
|
||||
|
||||
return wrappedAngle + min;
|
||||
return wrapped_angle + min;
|
||||
}
|
||||
} // namespace omath::angles
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace omath
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Mat<Columns, Rows, Type, StoreType> Transposed() const noexcept
|
||||
constexpr Mat<Columns, Rows, Type, StoreType> transposed() const noexcept
|
||||
{
|
||||
Mat<Columns, Rows, Type, StoreType> transposed;
|
||||
for (size_t i = 0; i < Rows; ++i)
|
||||
@@ -237,7 +237,7 @@ namespace omath
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Type Determinant() const
|
||||
constexpr Type determinant() const
|
||||
{
|
||||
static_assert(Rows == Columns, "Determinant is only defined for square matrices.");
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
constexpr Type minor(const size_t row, const size_t column) const
|
||||
{
|
||||
return strip(row, column).Determinant();
|
||||
return strip(row, column).determinant();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
@@ -355,17 +355,17 @@ namespace omath
|
||||
[[nodiscard]]
|
||||
constexpr std::optional<Mat> inverted() const
|
||||
{
|
||||
const auto det = Determinant();
|
||||
const auto det = determinant();
|
||||
|
||||
if (det == 0)
|
||||
return std::nullopt;
|
||||
|
||||
const auto transposed = Transposed();
|
||||
const auto transposed_mat = transposed();
|
||||
Mat result;
|
||||
|
||||
for (std::size_t row = 0; row < Rows; row++)
|
||||
for (std::size_t column = 0; column < Rows; column++)
|
||||
result.at(row, column) = transposed.alg_complement(row, column);
|
||||
result.at(row, column) = transposed_mat.alg_complement(row, column);
|
||||
|
||||
result /= det;
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@ namespace omath::pathfinding
|
||||
|
||||
[[nodiscard]]
|
||||
static auto get_perfect_node(const std::unordered_map<Vector3<float>, PathNode>& open_list,
|
||||
const Vector3<float>& endVertex);
|
||||
const Vector3<float>& end_vertex);
|
||||
};
|
||||
} // namespace omath::pathfinding
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace omath::projection
|
||||
float m_width;
|
||||
float m_height;
|
||||
|
||||
[[nodiscard]] constexpr float AspectRatio() const
|
||||
[[nodiscard]] constexpr float aspect_ratio() const
|
||||
{
|
||||
return m_width / m_height;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user