mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f1bc51905 | |||
| 71127f1f12 | |||
| 89041e20ae | |||
| a54dd4b52a | |||
| d7e497b617 | |||
| 80938cd913 | |||
| 830505dbe5 | |||
| 75565ecf2d | |||
| 9a7a4c7fff | |||
| c0f0bb3c2e |
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(omath VERSION 3.3.0 LANGUAGES CXX)
|
||||
project(omath VERSION 3.5.0 LANGUAGES CXX)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
@@ -39,6 +39,8 @@ endif ()
|
||||
|
||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
if (OMATH_IMGUI_INTEGRATION)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_IMGUI_INTEGRATION)
|
||||
|
||||
|
||||
16
include/omath/3d_primitives/plane.hpp
Normal file
16
include/omath/3d_primitives/plane.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Created by Vlad on 8/28/2025.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "omath/triangle.hpp"
|
||||
#include "omath/vector3.hpp"
|
||||
#include <array>
|
||||
|
||||
namespace omath::primitives
|
||||
{
|
||||
[[nodiscard]]
|
||||
std::array<Triangle<Vector3<float>>, 2> create_plane(const Vector3<float>& vertex_a,
|
||||
const Vector3<float>& vertex_b,
|
||||
const Vector3<float>& direction, float size) noexcept;
|
||||
}
|
||||
@@ -479,6 +479,35 @@ namespace omath
|
||||
{0.f, 0.f, -(far + near) / (far - near), -(2.f * near * far) / (far - near)},
|
||||
{0.f, 0.f, -1.f, 0.f}};
|
||||
}
|
||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
||||
[[nodiscard]]
|
||||
Mat<4, 4, Type, St> mat_ortho_left_handed(const Type left, const Type right,
|
||||
const Type bottom, const Type top,
|
||||
const Type near, const Type far) noexcept
|
||||
{
|
||||
return
|
||||
{
|
||||
{ static_cast<Type>(2) / (right - left), 0.f, 0.f, -(right + left) / (right - left)},
|
||||
{ 0.f, static_cast<Type>(2) / (top - bottom), 0.f, -(top + bottom) / (top - bottom)},
|
||||
{ 0.f, 0.f, static_cast<Type>(2) / (far - near), -(far + near) / (far - near) },
|
||||
{ 0.f, 0.f, 0.f, 1.f }
|
||||
};
|
||||
}
|
||||
template<class Type = float, MatStoreType St = MatStoreType::ROW_MAJOR>
|
||||
[[nodiscard]]
|
||||
Mat<4, 4, Type, St> mat_ortho_right_handed(const Type left, const Type right,
|
||||
const Type bottom, const Type top,
|
||||
const Type near, const Type far) noexcept
|
||||
{
|
||||
return
|
||||
{
|
||||
{ static_cast<Type>(2) / (right - left), 0.f, 0.f, -(right + left) / (right - left)},
|
||||
{ 0.f, static_cast<Type>(2) / (top - bottom), 0.f, -(top + bottom) / (top - bottom)},
|
||||
{ 0.f, 0.f, -static_cast<Type>(2) / (far - near), -(far + near) / (far - near) },
|
||||
{ 0.f, 0.f, 0.f, 1.f }
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace omath
|
||||
|
||||
template<size_t Rows, size_t Columns, class Type, omath::MatStoreType StoreType>
|
||||
|
||||
19
source/3d_primitives/plane.cpp
Normal file
19
source/3d_primitives/plane.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Created by Vlad on 8/28/2025.
|
||||
//
|
||||
#include "omath/3d_primitives/plane.hpp"
|
||||
|
||||
namespace omath::primitives
|
||||
{
|
||||
std::array<Triangle<Vector3<float>>, 2> create_plane(const Vector3<float>& vertex_a,
|
||||
const Vector3<float>& vertex_b,
|
||||
const Vector3<float>& direction, const float size) noexcept
|
||||
{
|
||||
const auto second_vertex_a = vertex_a + direction * size;
|
||||
return std::array
|
||||
{
|
||||
Triangle{second_vertex_a, vertex_a, vertex_b},
|
||||
Triangle{second_vertex_a, vertex_b + direction * size, vertex_b}
|
||||
};
|
||||
}
|
||||
} // namespace omath::primitives
|
||||
Reference in New Issue
Block a user