mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Adds project-specific IDE settings to improve code style consistency and development environment. Removes the .idea directory from the .gitignore file, as these files are now intended to be part of the project for consistent IDE configuration across contributors.
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
//
|
|
// Created by Orange on 11/30/2024.
|
|
//
|
|
#include <gtest/gtest.h>
|
|
#include <omath/angles.hpp>
|
|
|
|
TEST(unit_test_angles, radians_to_deg)
|
|
{
|
|
constexpr float rad = 67;
|
|
|
|
EXPECT_NEAR(omath::angles::radians_to_degrees(rad), 3838.82f, 0.01f);
|
|
}
|
|
|
|
TEST(unit_test_angles, degrees_to_radians)
|
|
{
|
|
constexpr float degree = 90;
|
|
|
|
EXPECT_NEAR(omath::angles::degrees_to_radians(degree), 1.5708f, 0.01f);
|
|
}
|
|
|
|
TEST(unit_test_angles, horizontal_fov_to_verical)
|
|
{
|
|
constexpr float h_fov = 90;
|
|
constexpr float aspect_ration = 16.0f / 9.0f;
|
|
const auto vertical_fov = omath::angles::horizontal_fov_to_vertical(h_fov, aspect_ration);
|
|
|
|
EXPECT_NEAR(vertical_fov, 58.71f, 0.01f);
|
|
}
|
|
|
|
TEST(unit_test_angles, vertical_to_horizontal)
|
|
{
|
|
constexpr float v_fov = 58.71;
|
|
constexpr float aspect_ration = 16.0f / 9.0f;
|
|
const auto horizontal_fov = omath::angles::vertical_fov_to_horizontal(v_fov, aspect_ration);
|
|
|
|
EXPECT_NEAR(horizontal_fov, 89.99f, 0.01f);
|
|
}
|
|
TEST(unit_test_angles, wrap_angle)
|
|
{
|
|
const float wrapped = omath::angles::wrap_angle(361.f, 0.f, 360.f);
|
|
|
|
EXPECT_NEAR(wrapped, 1.f, 0.01f);
|
|
}
|
|
TEST(unit_test_angles, wrap_angle_negative_range)
|
|
{
|
|
const float wrapped = omath::angles::wrap_angle(-90.f, 0.f, 360.f);
|
|
|
|
EXPECT_NEAR(wrapped, 270.f, 0.01f);
|
|
} |