mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-14 07:23:26 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| baf7ee8f88 | |||
| 9fde11733f | |||
| 0069b8bd96 | |||
| 127bae0b78 | |||
| bed204a663 | |||
| 3f6ea010dc | |||
| 592a98f38c | |||
| 7873047550 | |||
| 1601f3cbc8 | |||
| 2180f8ab97 | |||
| b613ff9ef1 |
@@ -3,9 +3,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "omath/angles.hpp"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include "omath/angles.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace omath
|
namespace omath
|
||||||
@@ -34,6 +34,7 @@ namespace omath
|
|||||||
std::unreachable();
|
std::unreachable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr static Angle FromDegrees(const Type& degrees)
|
constexpr static Angle FromDegrees(const Type& degrees)
|
||||||
@@ -42,7 +43,6 @@ namespace omath
|
|||||||
}
|
}
|
||||||
constexpr Angle() : m_angle(0)
|
constexpr Angle() : m_angle(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr static Angle FromRadians(const Type& degrees)
|
constexpr static Angle FromRadians(const Type& degrees)
|
||||||
@@ -149,4 +149,4 @@ namespace omath
|
|||||||
return Angle{-m_angle};
|
return Angle{-m_angle};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace omath
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ namespace omath::iw_engine
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Vector3<float> UpVector(const ViewAngles& angles);
|
Vector3<float> UpVector(const ViewAngles& angles);
|
||||||
|
|
||||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
[[nodiscard]]
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||||
|
|
||||||
|
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ namespace omath::opengl_engine
|
|||||||
using Mat4x4 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
using Mat4x4 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
||||||
using Mat3x3 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
using Mat3x3 = Mat<4, 4, float, MatStoreType::COLUMN_MAJOR>;
|
||||||
using Mat1x3 = Mat<1, 3, float, MatStoreType::COLUMN_MAJOR>;
|
using Mat1x3 = Mat<1, 3, float, MatStoreType::COLUMN_MAJOR>;
|
||||||
using PitchAngle = Angle<float, 0.f, 180.f, AngleFlags::Clamped>;
|
using PitchAngle = Angle<float, -90.f, 90.f, AngleFlags::Clamped>;
|
||||||
using YawAngle = Angle<float, 0.f, 360.f, AngleFlags::Normalized>;
|
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||||
using RollAngle = Angle<float, 0.f, 360.f, AngleFlags::Normalized>;
|
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||||
|
|
||||||
|
|
||||||
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
using ViewAngles = omath::ViewAngles<PitchAngle, YawAngle, RollAngle>;
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,8 @@ namespace omath::opengl_engine
|
|||||||
|
|
||||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ namespace omath::source_engine
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Vector3<float> ForwardVector(const ViewAngles& angles);
|
Vector3<float> ForwardVector(const ViewAngles& angles);
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Vector3<float> RightVector(const ViewAngles& angles);
|
Vector3<float> RightVector(const ViewAngles& angles);
|
||||||
|
|
||||||
@@ -17,7 +20,6 @@ namespace omath::source_engine
|
|||||||
|
|
||||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||||
} // namespace omath::source
|
} // namespace omath::source
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace omath::unity_engine
|
|||||||
using Mat4x4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
using Mat4x4 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||||
using Mat3x3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
using Mat3x3 = Mat<4, 4, float, MatStoreType::ROW_MAJOR>;
|
||||||
using Mat1x3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>;
|
using Mat1x3 = Mat<1, 3, float, MatStoreType::ROW_MAJOR>;
|
||||||
using PitchAngle = Angle<float, -89.f, 89.f, AngleFlags::Clamped>;
|
using PitchAngle = Angle<float, -90.f, 90.f, AngleFlags::Clamped>;
|
||||||
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
using YawAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||||
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
using RollAngle = Angle<float, -180.f, 180.f, AngleFlags::Normalized>;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace omath::unity_engine
|
|||||||
|
|
||||||
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
[[nodiscard]] Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin);
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles);
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
Mat4x4 CalcPerspectiveProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far);
|
||||||
|
|||||||
@@ -428,13 +428,6 @@ namespace omath
|
|||||||
} * MatTranslation<Type, St>(-cameraOrigin);
|
} * MatTranslation<Type, St>(-cameraOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR, class ViewAngles>
|
|
||||||
[[nodiscard]]
|
|
||||||
Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept
|
|
||||||
{
|
|
||||||
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Mat<4, 4, Type, St> MatPerspectiveLeftHanded(const float fieldOfView, const float aspectRatio, const float near,
|
Mat<4, 4, Type, St> MatPerspectiveLeftHanded(const float fieldOfView, const float aspectRatio, const float near,
|
||||||
|
|||||||
@@ -9,23 +9,27 @@ namespace omath::iw_engine
|
|||||||
|
|
||||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3<float> RightVector(const ViewAngles& angles)
|
Vector3<float> RightVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> UpVector(const ViewAngles& angles)
|
Vector3<float> UpVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||||
|
{
|
||||||
|
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
||||||
|
}
|
||||||
|
|
||||||
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
Mat4x4 CalcViewMatrix(const ViewAngles& angles, const Vector3<float>& cam_origin)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ namespace omath::opengl_engine
|
|||||||
|
|
||||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsForward);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> RightVector(const ViewAngles& angles)
|
Vector3<float> RightVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsRight);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> UpVector(const ViewAngles& angles)
|
Vector3<float> UpVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector<float, MatStoreType::COLUMN_MAJOR>(kAbsUp);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,12 @@ namespace omath::opengl_engine
|
|||||||
return MatCameraView<float, MatStoreType::COLUMN_MAJOR>(-ForwardVector(angles), RightVector(angles),
|
return MatCameraView<float, MatStoreType::COLUMN_MAJOR>(-ForwardVector(angles), RightVector(angles),
|
||||||
UpVector(angles), cam_origin);
|
UpVector(angles), cam_origin);
|
||||||
}
|
}
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||||
|
{
|
||||||
|
return MatRotationAxisZ<float, MatStoreType::COLUMN_MAJOR>(angles.roll) *
|
||||||
|
MatRotationAxisY<float, MatStoreType::COLUMN_MAJOR>(-angles.yaw) *
|
||||||
|
MatRotationAxisX<float, MatStoreType::COLUMN_MAJOR>(-angles.pitch);
|
||||||
|
}
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||||
const float far)
|
const float far)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,20 +8,25 @@ namespace omath::source_engine
|
|||||||
{
|
{
|
||||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||||
|
{
|
||||||
|
return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll);
|
||||||
|
}
|
||||||
|
|
||||||
Vector3<float> RightVector(const ViewAngles& angles)
|
Vector3<float> RightVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> UpVector(const ViewAngles& angles)
|
Vector3<float> UpVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ namespace omath::unity_engine
|
|||||||
{
|
{
|
||||||
Vector3<float> ForwardVector(const ViewAngles& angles)
|
Vector3<float> ForwardVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsForward);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsForward);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> RightVector(const ViewAngles& angles)
|
Vector3<float> RightVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsRight);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsRight);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
Vector3<float> UpVector(const ViewAngles& angles)
|
Vector3<float> UpVector(const ViewAngles& angles)
|
||||||
{
|
{
|
||||||
const auto vec = MatRotation(angles) * MatColumnFromVector(kAbsUp);
|
const auto vec = RotationMatrix(angles) * MatColumnFromVector(kAbsUp);
|
||||||
|
|
||||||
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
return {vec.At(0, 0), vec.At(1, 0), vec.At(2, 0)};
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,12 @@ namespace omath::unity_engine
|
|||||||
return MatCameraView<float, MatStoreType::ROW_MAJOR>(ForwardVector(angles), -RightVector(angles),
|
return MatCameraView<float, MatStoreType::ROW_MAJOR>(ForwardVector(angles), -RightVector(angles),
|
||||||
UpVector(angles), cam_origin);
|
UpVector(angles), cam_origin);
|
||||||
}
|
}
|
||||||
|
Mat4x4 RotationMatrix(const ViewAngles& angles)
|
||||||
|
{
|
||||||
|
return MatRotationAxisZ(angles.roll) *
|
||||||
|
MatRotationAxisY(angles.yaw) *
|
||||||
|
MatRotationAxisX(angles.pitch);
|
||||||
|
}
|
||||||
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
Mat4x4 CalcPerspectiveProjectionMatrix(const float fieldOfView, const float aspectRatio, const float near,
|
||||||
const float far)
|
const float far)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
// Created by Vlad on 2/23/2025.
|
// Created by Vlad on 2/23/2025.
|
||||||
//
|
//
|
||||||
#include "omath/projectile_prediction/proj_pred_engine_avx2.hpp"
|
#include "omath/projectile_prediction/proj_pred_engine_avx2.hpp"
|
||||||
#include "source_location"
|
#include <source_location>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
|
#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__)
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
#else
|
||||||
#include <format>
|
#include <format>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,42 @@ TEST(UnitTestIwEngine, UpVector)
|
|||||||
EXPECT_EQ(up, omath::iw_engine::kAbsUp);
|
EXPECT_EQ(up, omath::iw_engine::kAbsUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestIwEngine, ForwardVectorRotationYaw)
|
||||||
|
{
|
||||||
|
omath::iw_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.yaw = omath::iw_engine::YawAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::iw_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestIwEngine, ForwardVectorRotationPitch)
|
||||||
|
{
|
||||||
|
omath::iw_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.pitch = omath::iw_engine::PitchAngle::FromDegrees(-89.f);
|
||||||
|
|
||||||
|
const auto forward = omath::iw_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsUp.x, 0.02f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsUp.y, 0.01f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsUp.z, 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestIwEngine, ForwardVectorRotationRoll)
|
||||||
|
{
|
||||||
|
omath::iw_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.roll = omath::iw_engine::RollAngle::FromDegrees(90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::iw_engine::UpVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::iw_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::iw_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::iw_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(UnitTestIwEngine, ProjectTargetMovedFromCamera)
|
TEST(UnitTestIwEngine, ProjectTargetMovedFromCamera)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
|
|||||||
@@ -10,14 +10,12 @@
|
|||||||
TEST(UnitTestOpenGL, ForwardVector)
|
TEST(UnitTestOpenGL, ForwardVector)
|
||||||
{
|
{
|
||||||
const auto forward = omath::opengl_engine::ForwardVector({});
|
const auto forward = omath::opengl_engine::ForwardVector({});
|
||||||
|
|
||||||
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
|
EXPECT_EQ(forward, omath::opengl_engine::kAbsForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, RightVector)
|
TEST(UnitTestOpenGL, RightVector)
|
||||||
{
|
{
|
||||||
const auto right = omath::opengl_engine::RightVector({});
|
const auto right = omath::opengl_engine::RightVector({});
|
||||||
|
|
||||||
EXPECT_EQ(right, omath::opengl_engine::kAbsRight);
|
EXPECT_EQ(right, omath::opengl_engine::kAbsRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,6 +25,44 @@ TEST(UnitTestOpenGL, UpVector)
|
|||||||
EXPECT_EQ(up, omath::opengl_engine::kAbsUp);
|
EXPECT_EQ(up, omath::opengl_engine::kAbsUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestOpenGL, ForwardVectorRotationYaw)
|
||||||
|
{
|
||||||
|
omath::opengl_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.yaw = omath::opengl_engine::YawAngle::FromDegrees(90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::opengl_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TEST(UnitTestOpenGL, ForwardVectorRotationPitch)
|
||||||
|
{
|
||||||
|
omath::opengl_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.pitch = omath::opengl_engine::PitchAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::opengl_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsUp.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsUp.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsUp.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestOpenGL, ForwardVectorRotationRoll)
|
||||||
|
{
|
||||||
|
omath::opengl_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.roll = omath::opengl_engine::RollAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::opengl_engine::UpVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::opengl_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::opengl_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::opengl_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
TEST(UnitTestOpenGL, ProjectTargetMovedFromCamera)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
|
|||||||
@@ -27,6 +27,42 @@ TEST(UnitTestSourceEngine, UpVector)
|
|||||||
EXPECT_EQ(up, omath::source_engine::kAbsUp);
|
EXPECT_EQ(up, omath::source_engine::kAbsUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestSourceEngine, ForwardVectorRotationYaw)
|
||||||
|
{
|
||||||
|
omath::source_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.yaw = omath::source_engine::YawAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::source_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::source_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::source_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::source_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestSourceEngine, ForwardVectorRotationPitch)
|
||||||
|
{
|
||||||
|
omath::source_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.pitch = omath::source_engine::PitchAngle::FromDegrees(-89.f);
|
||||||
|
|
||||||
|
const auto forward = omath::source_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::source_engine::kAbsUp.x, 0.02f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::source_engine::kAbsUp.y, 0.01f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::source_engine::kAbsUp.z, 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestSourceEngine, ForwardVectorRotationRoll)
|
||||||
|
{
|
||||||
|
omath::source_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.roll = omath::source_engine::RollAngle::FromDegrees(90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::source_engine::UpVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::source_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::source_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::source_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
TEST(UnitTestSourceEngine, ProjectTargetMovedFromCamera)
|
||||||
{
|
{
|
||||||
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
constexpr auto fov = omath::projection::FieldOfView::FromDegrees(90.f);
|
||||||
|
|||||||
@@ -14,6 +14,42 @@ TEST(UnitTestUnityEngine, ForwardVector)
|
|||||||
EXPECT_EQ(forward, omath::unity_engine::kAbsForward);
|
EXPECT_EQ(forward, omath::unity_engine::kAbsForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestUnityEngine, ForwardVectorRotationYaw)
|
||||||
|
{
|
||||||
|
omath::unity_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.yaw = omath::unity_engine::YawAngle::FromDegrees(90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::unity_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestUnityEngine, ForwardVectorRotationPitch)
|
||||||
|
{
|
||||||
|
omath::unity_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.pitch = omath::unity_engine::PitchAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::unity_engine::ForwardVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsUp.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsUp.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsUp.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(UnitTestUnityEngine, ForwardVectorRotationRoll)
|
||||||
|
{
|
||||||
|
omath::unity_engine::ViewAngles angles;
|
||||||
|
|
||||||
|
angles.roll = omath::unity_engine::RollAngle::FromDegrees(-90.f);
|
||||||
|
|
||||||
|
const auto forward = omath::unity_engine::UpVector(angles);
|
||||||
|
EXPECT_NEAR(forward.x, omath::unity_engine::kAbsRight.x, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.y, omath::unity_engine::kAbsRight.y, 0.00001f);
|
||||||
|
EXPECT_NEAR(forward.z, omath::unity_engine::kAbsRight.z, 0.00001f);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(UnitTestUnityEngine, RightVector)
|
TEST(UnitTestUnityEngine, RightVector)
|
||||||
{
|
{
|
||||||
const auto right = omath::unity_engine::RightVector({});
|
const auto right = omath::unity_engine::RightVector({});
|
||||||
|
|||||||
Reference in New Issue
Block a user