Compare commits

...

28 Commits

Author SHA1 Message Date
a54a537239 fix 2025-06-17 21:34:25 +03:00
f01bbde537 added banner to repo 2025-06-17 21:33:39 +03:00
2c710555d6 fixed example 2025-06-16 01:40:14 +03:00
9c2be6306c Merge pull request #39 from orange-cpp/u/orange-cpp/writerside
U/orange cpp/writerside
2025-05-21 16:58:19 +03:00
d37840d4ef fixed stuff 2025-05-21 16:57:17 +03:00
b4a3b5d529 added text 2025-05-21 16:47:15 +03:00
c2a772142c fix 2025-05-21 16:47:15 +03:00
76fca7f527 fix 2025-05-21 16:47:15 +03:00
73ccd24e3e improved intro 2025-05-21 16:47:15 +03:00
a642feafb5 added new topic 2025-05-21 16:47:15 +03:00
faf9f34af8 stipped away text 2025-05-21 16:47:15 +03:00
b56801ac91 added files 2025-05-21 16:47:15 +03:00
a81d12d480 fixed version 2025-05-13 09:48:46 +03:00
17eb0cd0dc improved naming 2025-05-13 09:47:08 +03:00
52024285d2 added noexcept 2025-05-13 09:34:39 +03:00
f179aea4d7 removed even float type from vector classes 2025-05-13 09:22:23 +03:00
1196bb86b4 Merge pull request #44 from orange-cpp/feature/noexcept
Feature/noexcept
2025-05-05 02:34:43 +03:00
5489c296e9 added more noexcept 2025-05-05 02:24:23 +03:00
50ddf2d31e added more noexcept 2025-05-05 01:46:50 +03:00
a6e4c0461d added noexcept 2025-05-05 01:16:12 +03:00
6749f9f759 added noexcept for color and angles 2025-05-04 19:16:49 +03:00
9a38d47b0d added noexcept for vector types 2025-05-04 19:13:26 +03:00
f6f8bba032 changed license to zlib 2025-05-04 19:05:10 +03:00
ce08fcdd29 removed useless source files 2025-05-04 19:03:18 +03:00
49ea113348 fixed style 2025-05-04 18:54:33 +03:00
af21f9a946 removed pow 2025-05-04 18:07:35 +03:00
f096f7179f fixed clang format 2025-05-04 17:42:32 +03:00
e025e99d18 Update README.md 2025-05-04 00:55:35 +03:00
65 changed files with 639 additions and 371 deletions

View File

@@ -33,7 +33,7 @@ BraceWrapping:
BeforeWhile: true BeforeWhile: true
SplitEmptyRecord: true SplitEmptyRecord: true
SplitEmptyNamespace: true SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All BreakBeforeBinaryOperators: NonAssignment
BreakBeforeConceptDeclarations: false BreakBeforeConceptDeclarations: false
ColumnLimit: 120 ColumnLimit: 120
IncludeBlocks: Merge IncludeBlocks: Merge

BIN
.github/images/banner.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

View File

@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.26) cmake_minimum_required(VERSION 3.26)
project(omath VERSION 1.0.1 LANGUAGES CXX) project(omath VERSION 3.0.2 LANGUAGES CXX)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)

20
LICENSE
View File

@@ -1,9 +1,17 @@
The MIT License (MIT) Copyright (C) 2024-2025 Orange++ <orange-cpp@yandex.ru>
Copyright (c) 2024 Orange++ This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

View File

@@ -1,11 +1,12 @@
<div align = center> <div align = center>
![banner](https://i.imgur.com/SM9ccP6.png) ![banner](https://github.com/orange-cpp/omath/blob/main/.github/images/banner.png?raw=true)
![GitHub License](https://img.shields.io/github/license/orange-cpp/omath) ![GitHub License](https://img.shields.io/github/license/orange-cpp/omath)
![GitHub contributors](https://img.shields.io/github/contributors/orange-cpp/omath) ![GitHub contributors](https://img.shields.io/github/contributors/orange-cpp/omath)
![GitHub top language](https://img.shields.io/github/languages/top/orange-cpp/omath) ![GitHub top language](https://img.shields.io/github/languages/top/orange-cpp/omath)
[![CodeFactor](https://www.codefactor.io/repository/github/orange-cpp/omath/badge)](https://www.codefactor.io/repository/github/orange-cpp/omath) [![CodeFactor](https://www.codefactor.io/repository/github/orange-cpp/omath/badge)](https://www.codefactor.io/repository/github/orange-cpp/omath)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/orange-cpp/omath/cmake-multi-platform.yml)
![GitHub forks](https://img.shields.io/github/forks/orange-cpp/omath) ![GitHub forks](https://img.shields.io/github/forks/orange-cpp/omath)
</div> </div>

View File

@@ -15,8 +15,8 @@ int main()
float fov = 0; float fov = 0;
float near = 0; float near = 0;
float far = 0; float far = 0;
float viewPortWidth = 0; float view_port_width = 0;
float viewPortHeight = 0; float view_port_height = 0;
std::print("Enter camera fov: "); std::print("Enter camera fov: ");
std::cin >> fov; std::cin >> fov;
@@ -28,13 +28,13 @@ int main()
std::cin >> far; std::cin >> far;
std::print("Enter camera screen width: "); std::print("Enter camera screen width: ");
std::cin >> viewPortWidth; std::cin >> view_port_width;
std::print("Enter camera screen height: "); std::print("Enter camera screen height: ");
std::cin >> viewPortHeight; std::cin >> view_port_height;
const auto mat = const auto mat =
omath::opengl_engine::CalcPerspectiveProjectionMatrix(fov, viewPortWidth / viewPortHeight, near, far); omath::opengl_engine::calc_perspective_projection_matrix(fov, view_port_width / view_port_height, near, far);
std::print("{}", mat.ToString()); std::print("{}", mat.to_string());
}; };

View File

@@ -13,5 +13,5 @@ namespace omath::primitives
[[nodiscard]] [[nodiscard]]
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom, std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
const Vector3<float>& dir_forward, const Vector3<float>& dir_right, const Vector3<float>& dir_forward, const Vector3<float>& dir_right,
float ratio = 4.f); float ratio = 4.f) noexcept;
} }

View File

@@ -20,7 +20,7 @@ namespace omath
class Angle class Angle
{ {
Type m_angle; Type m_angle;
constexpr explicit Angle(const Type& degrees) constexpr explicit Angle(const Type& degrees) noexcept
{ {
if constexpr (flags == AngleFlags::Normalized) if constexpr (flags == AngleFlags::Normalized)
m_angle = angles::wrap_angle(degrees, min, max); m_angle = angles::wrap_angle(degrees, min, max);
@@ -36,68 +36,68 @@ namespace omath
public: public:
[[nodiscard]] [[nodiscard]]
constexpr static Angle from_degrees(const Type& degrees) constexpr static Angle from_degrees(const Type& degrees) noexcept
{ {
return Angle{degrees}; return Angle{degrees};
} }
constexpr Angle(): m_angle(0) constexpr Angle() noexcept: m_angle(0)
{ {
} }
[[nodiscard]] [[nodiscard]]
constexpr static Angle from_radians(const Type& degrees) constexpr static Angle from_radians(const Type& degrees) noexcept
{ {
return Angle{angles::radians_to_degrees<Type>(degrees)}; return Angle{angles::radians_to_degrees<Type>(degrees)};
} }
[[nodiscard]] [[nodiscard]]
constexpr const Type& operator*() const constexpr const Type& operator*() const noexcept
{ {
return m_angle; return m_angle;
} }
[[nodiscard]] [[nodiscard]]
constexpr Type as_degrees() const constexpr Type as_degrees() const noexcept
{ {
return m_angle; return m_angle;
} }
[[nodiscard]] [[nodiscard]]
constexpr Type as_radians() const constexpr Type as_radians() const noexcept
{ {
return angles::degrees_to_radians(m_angle); return angles::degrees_to_radians(m_angle);
} }
[[nodiscard]] [[nodiscard]]
Type sin() const Type sin() const noexcept
{ {
return std::sin(as_radians()); return std::sin(as_radians());
} }
[[nodiscard]] [[nodiscard]]
Type cos() const Type cos() const noexcept
{ {
return std::cos(as_radians()); return std::cos(as_radians());
} }
[[nodiscard]] [[nodiscard]]
Type tan() const Type tan() const noexcept
{ {
return std::tan(as_radians()); return std::tan(as_radians());
} }
[[nodiscard]] [[nodiscard]]
Type atan() const Type atan() const noexcept
{ {
return std::atan(as_radians()); return std::atan(as_radians());
} }
[[nodiscard]] [[nodiscard]]
Type cot() const Type cot() const noexcept
{ {
return cos() / sin(); return cos() / sin();
} }
constexpr Angle& operator+=(const Angle& other) constexpr Angle& operator+=(const Angle& other) noexcept
{ {
if constexpr (flags == AngleFlags::Normalized) if constexpr (flags == AngleFlags::Normalized)
m_angle = angles::wrap_angle(m_angle + other.m_angle, min, max); m_angle = angles::wrap_angle(m_angle + other.m_angle, min, max);
@@ -114,16 +114,15 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr std::partial_ordering operator<=>(const Angle& other) const constexpr std::partial_ordering operator<=>(const Angle& other) const noexcept = default;
= default;
constexpr Angle& operator-=(const Angle& other) constexpr Angle& operator-=(const Angle& other) noexcept
{ {
return operator+=(-other); return operator+=(-other);
} }
[[nodiscard]] [[nodiscard]]
constexpr Angle& operator+(const Angle& other) constexpr Angle& operator+(const Angle& other) noexcept
{ {
if constexpr (flags == AngleFlags::Normalized) if constexpr (flags == AngleFlags::Normalized)
return {angles::wrap_angle(m_angle + other.m_angle, min, max)}; return {angles::wrap_angle(m_angle + other.m_angle, min, max)};
@@ -138,13 +137,13 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr Angle& operator-(const Angle& other) constexpr Angle& operator-(const Angle& other) noexcept
{ {
return operator+(-other); return operator+(-other);
} }
[[nodiscard]] [[nodiscard]]
constexpr Angle operator-() const constexpr Angle operator-() const noexcept
{ {
return Angle{-m_angle}; return Angle{-m_angle};
} }

View File

@@ -10,21 +10,21 @@ namespace omath::angles
{ {
template<class Type> template<class Type>
requires std::is_floating_point_v<Type> requires std::is_floating_point_v<Type>
[[nodiscard]] constexpr Type radians_to_degrees(const Type& radians) [[nodiscard]] constexpr Type radians_to_degrees(const Type& radians) noexcept
{ {
return radians * (static_cast<Type>(180) / std::numbers::pi_v<Type>); return radians * (static_cast<Type>(180) / std::numbers::pi_v<Type>);
} }
template<class Type> template<class Type>
requires std::is_floating_point_v<Type> requires std::is_floating_point_v<Type>
[[nodiscard]] constexpr Type degrees_to_radians(const Type& degrees) [[nodiscard]] constexpr Type degrees_to_radians(const Type& degrees) noexcept
{ {
return degrees * (std::numbers::pi_v<Type> / static_cast<Type>(180)); return degrees * (std::numbers::pi_v<Type> / static_cast<Type>(180));
} }
template<class Type> template<class Type>
requires std::is_floating_point_v<Type> requires std::is_floating_point_v<Type>
[[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect) [[nodiscard]] Type horizontal_fov_to_vertical(const Type& horizontal_fov, const Type& aspect) noexcept
{ {
const auto fov_rad = degrees_to_radians(horizontal_fov); const auto fov_rad = degrees_to_radians(horizontal_fov);
@@ -35,19 +35,19 @@ namespace omath::angles
template<class Type> template<class Type>
requires std::is_floating_point_v<Type> requires std::is_floating_point_v<Type>
[[nodiscard]] Type vertical_fov_to_horizontal(const Type& vertical_fov, const Type& aspect) [[nodiscard]] Type vertical_fov_to_horizontal(const Type& vertical_fov, const Type& aspect) noexcept
{ {
const auto fov_as_radians = degrees_to_radians(vertical_fov); const auto fov_as_radians = degrees_to_radians(vertical_fov);
const auto horizontal_fov const auto horizontal_fov =
= static_cast<Type>(2) * std::atan(std::tan(fov_as_radians / static_cast<Type>(2)) * aspect); static_cast<Type>(2) * std::atan(std::tan(fov_as_radians / static_cast<Type>(2)) * aspect);
return radians_to_degrees(horizontal_fov); return radians_to_degrees(horizontal_fov);
} }
template<class Type> template<class Type>
requires std::is_arithmetic_v<Type> requires std::is_arithmetic_v<Type>
[[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max) [[nodiscard]] Type wrap_angle(const Type& angle, const Type& min, const Type& max) noexcept
{ {
if (angle <= max && angle >= min) if (angle <= max && angle >= min)
return angle; return angle;

View File

@@ -16,10 +16,10 @@ namespace omath::collision
bool infinite_length = false; bool infinite_length = false;
[[nodiscard]] [[nodiscard]]
Vector3<float> direction_vector() const; Vector3<float> direction_vector() const noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> direction_vector_normalized() const; Vector3<float> direction_vector_normalized() const noexcept;
}; };
class LineTracer class LineTracer
{ {
@@ -27,11 +27,11 @@ namespace omath::collision
LineTracer() = delete; LineTracer() = delete;
[[nodiscard]] [[nodiscard]]
static bool can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle); static bool can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
// Realization of MöllerTrumbore intersection algorithm // Realization of MöllerTrumbore intersection algorithm
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm // https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
[[nodiscard]] [[nodiscard]]
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle); static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
}; };
} // namespace omath::collision } // namespace omath::collision

View File

@@ -28,20 +28,20 @@ namespace omath
class Color final : public Vector4<float> class Color final : public Vector4<float>
{ {
public: public:
constexpr Color(const float r, const float g, const float b, const float a): Vector4(r, g, b, a) constexpr Color(const float r, const float g, const float b, const float a) noexcept: Vector4(r, g, b, a)
{ {
clamp(0.f, 1.f); clamp(0.f, 1.f);
} }
constexpr explicit Color() = default; constexpr explicit Color() noexcept = default;
[[nodiscard]] [[nodiscard]]
constexpr static Color from_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a) constexpr static Color from_rgba(const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a) noexcept
{ {
return Color{Vector4(r, g, b, a) / 255.f}; return Color{Vector4(r, g, b, a) / 255.f};
} }
[[nodiscard]] [[nodiscard]]
constexpr static Color from_hsv(float hue, const float saturation, const float value) constexpr static Color from_hsv(float hue, const float saturation, const float value) noexcept
{ {
float r{}, g{}, b{}; float r{}, g{}, b{};
@@ -82,13 +82,13 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr static Color from_hsv(const Hsv& hsv) constexpr static Color from_hsv(const Hsv& hsv) noexcept
{ {
return from_hsv(hsv.hue, hsv.saturation, hsv.value); return from_hsv(hsv.hue, hsv.saturation, hsv.value);
} }
[[nodiscard]] [[nodiscard]]
constexpr Hsv to_hsv() const constexpr Hsv to_hsv() const noexcept
{ {
Hsv hsv_data; Hsv hsv_data;
@@ -120,11 +120,11 @@ namespace omath
return hsv_data; return hsv_data;
} }
constexpr explicit Color(const Vector4& vec): Vector4(vec) constexpr explicit Color(const Vector4& vec) noexcept: Vector4(vec)
{ {
clamp(0.f, 1.f); clamp(0.f, 1.f);
} }
constexpr void set_hue(const float hue) constexpr void set_hue(const float hue) noexcept
{ {
auto hsv = to_hsv(); auto hsv = to_hsv();
hsv.hue = hue; hsv.hue = hue;
@@ -132,7 +132,7 @@ namespace omath
*this = from_hsv(hsv); *this = from_hsv(hsv);
} }
constexpr void set_saturation(const float saturation) constexpr void set_saturation(const float saturation) noexcept
{ {
auto hsv = to_hsv(); auto hsv = to_hsv();
hsv.saturation = saturation; hsv.saturation = saturation;
@@ -140,7 +140,7 @@ namespace omath
*this = from_hsv(hsv); *this = from_hsv(hsv);
} }
constexpr void set_value(const float value) constexpr void set_value(const float value) noexcept
{ {
auto hsv = to_hsv(); auto hsv = to_hsv();
hsv.value = value; hsv.value = value;
@@ -148,7 +148,7 @@ namespace omath
*this = from_hsv(hsv); *this = from_hsv(hsv);
} }
[[nodiscard]] [[nodiscard]]
constexpr Color blend(const Color& other, float ratio) const constexpr Color blend(const Color& other, float ratio) const noexcept
{ {
ratio = std::clamp(ratio, 0.f, 1.f); ratio = std::clamp(ratio, 0.f, 1.f);
return Color(*this * (1.f - ratio) + other * ratio); return Color(*this * (1.f - ratio) + other * ratio);

View File

@@ -16,7 +16,7 @@ namespace omath::iw_engine
void look_at(const Vector3<float>& target) override; void look_at(const Vector3<float>& target) override;
protected: protected:
[[nodiscard]] Mat4X4 calc_view_matrix() const override; [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
[[nodiscard]] Mat4X4 calc_projection_matrix() const override; [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
}; };
} // namespace omath::iw_engine } // namespace omath::iw_engine

View File

@@ -8,19 +8,19 @@
namespace omath::iw_engine namespace omath::iw_engine
{ {
[[nodiscard]] [[nodiscard]]
Vector3<float> forward_vector(const ViewAngles& angles); Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> right_vector(const ViewAngles& angles); Vector3<float> right_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> up_vector(const ViewAngles& angles); Vector3<float> up_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 rotation_matrix(const ViewAngles& angles); Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin); [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
} // namespace omath::iw_engine } // namespace omath::iw_engine

View File

@@ -13,7 +13,7 @@ namespace omath::opengl_engine
Camera(const Vector3<float>& position, const ViewAngles& view_angles, const projection::ViewPort& view_port, Camera(const Vector3<float>& position, const ViewAngles& view_angles, const projection::ViewPort& view_port,
const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far); const Angle<float, 0.f, 180.f, AngleFlags::Clamped>& fov, float near, float far);
void look_at(const Vector3<float>& target) override; void look_at(const Vector3<float>& target) override;
[[nodiscard]] Mat4X4 calc_view_matrix() const override; [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
[[nodiscard]] Mat4X4 calc_projection_matrix() const override; [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
}; };
} // namespace omath::opengl_engine } // namespace omath::opengl_engine

View File

@@ -8,19 +8,19 @@
namespace omath::opengl_engine namespace omath::opengl_engine
{ {
[[nodiscard]] [[nodiscard]]
Vector3<float> forward_vector(const ViewAngles& angles); Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> right_vector(const ViewAngles& angles); Vector3<float> right_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> up_vector(const ViewAngles& angles); Vector3<float> up_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin); [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 rotation_matrix(const ViewAngles& angles); Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
} // namespace omath::opengl_engine } // namespace omath::opengl_engine

View File

@@ -15,7 +15,7 @@ namespace omath::source_engine
void look_at(const Vector3<float>& target) override; void look_at(const Vector3<float>& target) override;
protected: protected:
[[nodiscard]] Mat4X4 calc_view_matrix() const override; [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
[[nodiscard]] Mat4X4 calc_projection_matrix() const override; [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
}; };
} // namespace omath::source_engine } // namespace omath::source_engine

View File

@@ -7,19 +7,19 @@
namespace omath::source_engine namespace omath::source_engine
{ {
[[nodiscard]] [[nodiscard]]
Vector3<float> forward_vector(const ViewAngles& angles); Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 rotation_matrix(const ViewAngles& angles); Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> right_vector(const ViewAngles& angles); Vector3<float> right_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> up_vector(const ViewAngles& angles); Vector3<float> up_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin); [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
} // namespace omath::source_engine } // namespace omath::source_engine

View File

@@ -16,7 +16,7 @@ namespace omath::unity_engine
void look_at(const Vector3<float>& target) override; void look_at(const Vector3<float>& target) override;
protected: protected:
[[nodiscard]] Mat4X4 calc_view_matrix() const override; [[nodiscard]] Mat4X4 calc_view_matrix() const noexcept override;
[[nodiscard]] Mat4X4 calc_projection_matrix() const override; [[nodiscard]] Mat4X4 calc_projection_matrix() const noexcept override;
}; };
} // namespace omath::unity_engine } // namespace omath::unity_engine

View File

@@ -8,19 +8,19 @@
namespace omath::unity_engine namespace omath::unity_engine
{ {
[[nodiscard]] [[nodiscard]]
Vector3<float> forward_vector(const ViewAngles& angles); Vector3<float> forward_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> right_vector(const ViewAngles& angles); Vector3<float> right_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Vector3<float> up_vector(const ViewAngles& angles); Vector3<float> up_vector(const ViewAngles& angles) noexcept;
[[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin); [[nodiscard]] Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 rotation_matrix(const ViewAngles& angles); Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
[[nodiscard]] [[nodiscard]]
Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far); Mat4X4 calc_perspective_projection_matrix(float field_of_view, float aspect_ratio, float near, float far) noexcept;
} // namespace omath::unity_engine } // namespace omath::unity_engine

View File

@@ -451,7 +451,6 @@ namespace omath
{up.x, up.y, up.z, 0}, {up.x, up.y, up.z, 0},
{forward.x, forward.y, forward.z, 0}, {forward.x, forward.y, forward.z, 0},
{0, 0, 0, 1}, {0, 0, 0, 1},
} * mat_translation<Type, St>(-camera_origin); } * mat_translation<Type, St>(-camera_origin);
} }

View File

@@ -15,16 +15,16 @@ namespace omath::pathfinding
public: public:
[[nodiscard]] [[nodiscard]]
static std::vector<Vector3<float>> find_path(const Vector3<float>& start, const Vector3<float>& end, static std::vector<Vector3<float>> find_path(const Vector3<float>& start, const Vector3<float>& end,
const NavigationMesh& nav_mesh); const NavigationMesh& nav_mesh) noexcept;
private: private:
[[nodiscard]] [[nodiscard]]
static std::vector<Vector3<float>> static std::vector<Vector3<float>>
reconstruct_final_path(const std::unordered_map<Vector3<float>, PathNode>& closed_list, reconstruct_final_path(const std::unordered_map<Vector3<float>, PathNode>& closed_list,
const Vector3<float>& current); const Vector3<float>& current) noexcept;
[[nodiscard]] [[nodiscard]]
static auto get_perfect_node(const std::unordered_map<Vector3<float>, PathNode>& open_list, static auto get_perfect_node(const std::unordered_map<Vector3<float>, PathNode>& open_list,
const Vector3<float>& end_vertex); const Vector3<float>& end_vertex) noexcept;
}; };
} // namespace omath::pathfinding } // namespace omath::pathfinding

View File

@@ -14,24 +14,23 @@ namespace omath::pathfinding
enum Error enum Error
{ {
}; };
class NavigationMesh final class NavigationMesh final
{ {
public: public:
[[nodiscard]] [[nodiscard]]
std::expected<Vector3<float>, std::string> get_closest_vertex(const Vector3<float>& point) const; std::expected<Vector3<float>, std::string> get_closest_vertex(const Vector3<float>& point) const noexcept;
[[nodiscard]] [[nodiscard]]
const std::vector<Vector3<float>>& get_neighbors(const Vector3<float>& vertex) const; const std::vector<Vector3<float>>& get_neighbors(const Vector3<float>& vertex) const noexcept;
[[nodiscard]] [[nodiscard]]
bool empty() const; bool empty() const;
[[nodiscard]] std::vector<uint8_t> serialize() const; [[nodiscard]] std::vector<uint8_t> serialize() const noexcept;
void deserialize(const std::vector<uint8_t>& raw); void deserialize(const std::vector<uint8_t>& raw) noexcept;
std::unordered_map<Vector3<float>, std::vector<Vector3<float>>> m_vertex_map; std::unordered_map<Vector3<float>, std::vector<Vector3<float>>> m_vertex_map;
}; };

View File

@@ -9,8 +9,8 @@ namespace omath::projectile_prediction
class ProjPredEngineAvx2 final : public ProjPredEngine class ProjPredEngineAvx2 final : public ProjPredEngine
{ {
public: public:
[[nodiscard]] std::optional<Vector3<float>> maybe_calculate_aim_point(const Projectile& projectile, [[nodiscard]] std::optional<Vector3<float>>
const Target& target) const override; maybe_calculate_aim_point(const Projectile& projectile, const Target& target) const override;
ProjPredEngineAvx2(float gravity_constant, float simulation_time_step, float maximum_simulation_time); ProjPredEngineAvx2(float gravity_constant, float simulation_time_step, float maximum_simulation_time);
~ProjPredEngineAvx2() override = default; ~ProjPredEngineAvx2() override = default;
@@ -18,7 +18,7 @@ namespace omath::projectile_prediction
private: private:
[[nodiscard]] static std::optional<float> calculate_pitch(const Vector3<float>& proj_origin, [[nodiscard]] static std::optional<float> calculate_pitch(const Vector3<float>& proj_origin,
const Vector3<float>& target_pos, const Vector3<float>& target_pos,
float bullet_gravity, float v0, float time); float bullet_gravity, float v0, float time) ;
// We use [[maybe_unused]] here since AVX2 is not available for ARM and ARM64 CPU // We use [[maybe_unused]] here since AVX2 is not available for ARM and ARM64 CPU
[[maybe_unused]] const float m_gravity_constant; [[maybe_unused]] const float m_gravity_constant;

View File

@@ -29,11 +29,12 @@ namespace omath::projectile_prediction
const float m_distance_tolerance; const float m_distance_tolerance;
[[nodiscard]] [[nodiscard]]
std::optional<float> maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile, std::optional<float>
const Vector3<float>& target_position) const; maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile,
const Vector3<float>& target_position) const noexcept;
[[nodiscard]] [[nodiscard]]
bool is_projectile_reached_target(const Vector3<float>& target_position, const Projectile& projectile, bool is_projectile_reached_target(const Vector3<float>& target_position, const Projectile& projectile,
float pitch, float time) const; float pitch, float time) const noexcept;
}; };
} // namespace omath::projectile_prediction } // namespace omath::projectile_prediction

View File

@@ -11,7 +11,7 @@ namespace omath::projectile_prediction
{ {
public: public:
[[nodiscard]] [[nodiscard]]
Vector3<float> predict_position(float pitch, float yaw, float time, float gravity) const; Vector3<float> predict_position(float pitch, float yaw, float time, float gravity) const noexcept;
Vector3<float> m_origin; Vector3<float> m_origin;
float m_launch_speed{}; float m_launch_speed{};

View File

@@ -11,12 +11,12 @@ namespace omath::projectile_prediction
{ {
public: public:
[[nodiscard]] [[nodiscard]]
constexpr Vector3<float> predict_position(const float time, const float gravity) const constexpr Vector3<float> predict_position(const float time, const float gravity) const noexcept
{ {
auto predicted = m_origin + m_velocity * time; auto predicted = m_origin + m_velocity * time;
if (m_is_airborne) if (m_is_airborne)
predicted.z -= gravity * std::pow(time, 2.f) * 0.5f; predicted.z -= gravity * (time*time) * 0.5f;
return predicted; return predicted;
} }

View File

@@ -32,7 +32,7 @@ namespace omath::projection
public: public:
virtual ~Camera() = default; virtual ~Camera() = default;
Camera(const Vector3<float>& position, const ViewAnglesType& view_angles, const ViewPort& view_port, Camera(const Vector3<float>& position, const ViewAnglesType& view_angles, const ViewPort& view_port,
const FieldOfView& fov, const float near, const float far) const FieldOfView& fov, const float near, const float far) noexcept
: m_view_port(view_port), m_field_of_view(fov), m_far_plane_distance(far), m_near_plane_distance(near), : m_view_port(view_port), m_field_of_view(fov), m_far_plane_distance(far), m_near_plane_distance(near),
m_view_angles(view_angles), m_origin(position) m_view_angles(view_angles), m_origin(position)
{ {
@@ -41,17 +41,17 @@ namespace omath::projection
protected: protected:
virtual void look_at(const Vector3<float>& target) = 0; virtual void look_at(const Vector3<float>& target) = 0;
[[nodiscard]] virtual Mat4X4Type calc_view_matrix() const = 0; [[nodiscard]] virtual Mat4X4Type calc_view_matrix() const noexcept = 0;
[[nodiscard]] virtual Mat4X4Type calc_projection_matrix() const = 0; [[nodiscard]] virtual Mat4X4Type calc_projection_matrix() const noexcept = 0;
[[nodiscard]] Mat4X4Type calc_view_projection_matrix() const [[nodiscard]] Mat4X4Type calc_view_projection_matrix() const noexcept
{ {
return calc_projection_matrix() * calc_view_matrix(); return calc_projection_matrix() * calc_view_matrix();
} }
public: public:
[[nodiscard]] const Mat4X4Type& get_view_projection_matrix() const [[nodiscard]] const Mat4X4Type& get_view_projection_matrix() const noexcept
{ {
if (!m_view_projection_matrix.has_value()) if (!m_view_projection_matrix.has_value())
m_view_projection_matrix = calc_view_projection_matrix(); m_view_projection_matrix = calc_view_projection_matrix();
@@ -59,68 +59,69 @@ namespace omath::projection
return m_view_projection_matrix.value(); return m_view_projection_matrix.value();
} }
void set_field_of_view(const FieldOfView& fov) void set_field_of_view(const FieldOfView& fov) noexcept
{ {
m_field_of_view = fov; m_field_of_view = fov;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
void set_near_plane(const float near) void set_near_plane(const float near) noexcept
{ {
m_near_plane_distance = near; m_near_plane_distance = near;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
void set_far_plane(const float far) void set_far_plane(const float far) noexcept
{ {
m_far_plane_distance = far; m_far_plane_distance = far;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
void set_view_angles(const ViewAnglesType& view_angles) void set_view_angles(const ViewAnglesType& view_angles) noexcept
{ {
m_view_angles = view_angles; m_view_angles = view_angles;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
void set_origin(const Vector3<float>& origin) void set_origin(const Vector3<float>& origin) noexcept
{ {
m_origin = origin; m_origin = origin;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
void set_view_port(const ViewPort& view_port) void set_view_port(const ViewPort& view_port) noexcept
{ {
m_view_port = view_port; m_view_port = view_port;
m_view_projection_matrix = std::nullopt; m_view_projection_matrix = std::nullopt;
} }
[[nodiscard]] const FieldOfView& get_field_of_view() const [[nodiscard]] const FieldOfView& get_field_of_view() const noexcept
{ {
return m_field_of_view; return m_field_of_view;
} }
[[nodiscard]] const float& get_near_plane() const [[nodiscard]] const float& get_near_plane() const noexcept
{ {
return m_near_plane_distance; return m_near_plane_distance;
} }
[[nodiscard]] const float& get_far_plane() const [[nodiscard]] const float& get_far_plane() const noexcept
{ {
return m_far_plane_distance; return m_far_plane_distance;
} }
[[nodiscard]] const ViewAnglesType& get_view_angles() const [[nodiscard]] const ViewAnglesType& get_view_angles() const noexcept
{ {
return m_view_angles; return m_view_angles;
} }
[[nodiscard]] const Vector3<float>& get_origin() const [[nodiscard]] const Vector3<float>& get_origin() const noexcept
{ {
return m_origin; return m_origin;
} }
[[nodiscard]] std::expected<Vector3<float>, Error> world_to_screen(const Vector3<float>& world_position) const [[nodiscard]] std::expected<Vector3<float>, Error>
world_to_screen(const Vector3<float>& world_position) const noexcept
{ {
auto normalized_cords = world_to_view_port(world_position); auto normalized_cords = world_to_view_port(world_position);
@@ -131,7 +132,7 @@ namespace omath::projection
} }
[[nodiscard]] std::expected<Vector3<float>, Error> [[nodiscard]] std::expected<Vector3<float>, Error>
world_to_view_port(const Vector3<float>& world_position) const world_to_view_port(const Vector3<float>& world_position) const noexcept
{ {
auto projected = get_view_projection_matrix() auto projected = get_view_projection_matrix()
* mat_column_from_vector<float, Mat4X4Type::get_store_ordering()>(world_position); * mat_column_from_vector<float, Mat4X4Type::get_store_ordering()>(world_position);
@@ -160,13 +161,13 @@ namespace omath::projection
Vector3<float> m_origin; Vector3<float> m_origin;
private: private:
template<class Type> [[nodiscard]] template<class Type>
constexpr static bool is_ndc_out_of_bounds(const Type& ndc) [[nodiscard]] constexpr static bool is_ndc_out_of_bounds(const Type& ndc) noexcept
{ {
return std::ranges::any_of(ndc.raw_array(), [](const auto& val) { return val < -1 || val > 1; }); return std::ranges::any_of(ndc.raw_array(), [](const auto& val) { return val < -1 || val > 1; });
} }
[[nodiscard]] Vector3<float> ndc_to_screen_position(const Vector3<float>& ndc) const [[nodiscard]] Vector3<float> ndc_to_screen_position(const Vector3<float>& ndc) const noexcept
{ {
return {(ndc.x + 1.f) / 2.f * m_view_port.m_width, (1.f - ndc.y) / 2.f * m_view_port.m_height, ndc.z}; return {(ndc.x + 1.f) / 2.f * m_view_port.m_width, (1.f - ndc.y) / 2.f * m_view_port.m_height, ndc.z};
} }

View File

@@ -24,133 +24,133 @@ namespace omath
// Constructors // Constructors
constexpr Vector2() = default; constexpr Vector2() = default;
constexpr Vector2(const Type& x, const Type& y): x(x), y(y) constexpr Vector2(const Type& x, const Type& y) noexcept: x(x), y(y)
{ {
} }
// Equality operators // Equality operators
[[nodiscard]] [[nodiscard]]
constexpr bool operator==(const Vector2& src) const constexpr bool operator==(const Vector2& other) const noexcept
{ {
return x == src.x && y == src.y; return x == other.x && y == other.y;
} }
[[nodiscard]] [[nodiscard]]
constexpr bool operator!=(const Vector2& src) const constexpr bool operator!=(const Vector2& other) const noexcept
{ {
return !(*this == src); return !(*this == other);
} }
// Compound assignment operators // Compound assignment operators
constexpr Vector2& operator+=(const Vector2& v) constexpr Vector2& operator+=(const Vector2& other) noexcept
{ {
x += v.x; x += other.x;
y += v.y; y += other.y;
return *this; return *this;
} }
constexpr Vector2& operator-=(const Vector2& v) constexpr Vector2& operator-=(const Vector2& other) noexcept
{ {
x -= v.x; x -= other.x;
y -= v.y; y -= other.y;
return *this; return *this;
} }
constexpr Vector2& operator*=(const Vector2& v) constexpr Vector2& operator*=(const Vector2& other) noexcept
{ {
x *= v.x; x *= other.x;
y *= v.y; y *= other.y;
return *this; return *this;
} }
constexpr Vector2& operator/=(const Vector2& v) constexpr Vector2& operator/=(const Vector2& other) noexcept
{ {
x /= v.x; x /= other.x;
y /= v.y; y /= other.y;
return *this; return *this;
} }
constexpr Vector2& operator*=(const Type& fl) constexpr Vector2& operator*=(const Type& value) noexcept
{ {
x *= fl; x *= value;
y *= fl; y *= value;
return *this; return *this;
} }
constexpr Vector2& operator/=(const Type& fl) constexpr Vector2& operator/=(const Type& value) noexcept
{ {
x /= fl; x /= value;
y /= fl; y /= value;
return *this; return *this;
} }
constexpr Vector2& operator+=(const Type& fl) constexpr Vector2& operator+=(const Type& value) noexcept
{ {
x += fl; x += value;
y += fl; y += value;
return *this; return *this;
} }
constexpr Vector2& operator-=(const Type& fl) constexpr Vector2& operator-=(const Type& value) noexcept
{ {
x -= fl; x -= value;
y -= fl; y -= value;
return *this; return *this;
} }
// Basic vector operations // Basic vector operations
[[nodiscard]] Type distance_to(const Vector2& other) const [[nodiscard]] Type distance_to(const Vector2& other) const noexcept
{ {
return std::sqrt(distance_to_sqr(other)); return std::sqrt(distance_to_sqr(other));
} }
[[nodiscard]] constexpr Type distance_to_sqr(const Vector2& other) const [[nodiscard]] constexpr Type distance_to_sqr(const Vector2& other) const noexcept
{ {
return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y); return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y);
} }
[[nodiscard]] constexpr Type dot(const Vector2& other) const [[nodiscard]] constexpr Type dot(const Vector2& other) const noexcept
{ {
return x * other.x + y * other.y; return x * other.x + y * other.y;
} }
#ifndef _MSC_VER #ifndef _MSC_VER
[[nodiscard]] constexpr Type length() const [[nodiscard]] constexpr Type length() const noexcept
{ {
return std::hypot(this->x, this->y); return std::hypot(this->x, this->y);
} }
[[nodiscard]] constexpr Vector2 normalized() const [[nodiscard]] constexpr Vector2 normalized() const noexcept
{ {
const Type len = length(); const Type len = length();
return len > 0.f ? *this / len : *this; return len > 0.f ? *this / len : *this;
} }
#else #else
[[nodiscard]] Type length() const [[nodiscard]] Type length() const noexcept
{ {
return std::hypot(x, y); return std::hypot(x, y);
} }
[[nodiscard]] Vector2 normalized() const [[nodiscard]] Vector2 normalized() const noexcept
{ {
const Type len = length(); const Type len = length();
return len > 0.f ? *this / len : *this; return len > 0.f ? *this / len : *this;
} }
#endif #endif
[[nodiscard]] constexpr Type length_sqr() const [[nodiscard]] constexpr Type length_sqr() const noexcept
{ {
return x * x + y * y; return x * x + y * y;
} }
constexpr Vector2& abs() constexpr Vector2& abs() noexcept
{ {
// FIXME: Replace with std::abs, if it will become constexprable // FIXME: Replace with std::abs, if it will become constexprable
x = x < 0 ? -x : x; x = x < 0 ? -x : x;
@@ -158,47 +158,47 @@ namespace omath
return *this; return *this;
} }
[[nodiscard]] constexpr Vector2 operator-() const [[nodiscard]] constexpr Vector2 operator-() const noexcept
{ {
return {-x, -y}; return {-x, -y};
} }
// Binary arithmetic operators // Binary arithmetic operators
[[nodiscard]] constexpr Vector2 operator+(const Vector2& v) const [[nodiscard]] constexpr Vector2 operator+(const Vector2& other) const noexcept
{ {
return {x + v.x, y + v.y}; return {x + other.x, y + other.y};
} }
[[nodiscard]] constexpr Vector2 operator-(const Vector2& v) const [[nodiscard]] constexpr Vector2 operator-(const Vector2& other) const noexcept
{ {
return {x - v.x, y - v.y}; return {x - other.x, y - other.y};
} }
[[nodiscard]] constexpr Vector2 operator*(const float fl) const [[nodiscard]] constexpr Vector2 operator*(const Type& value) const noexcept
{ {
return {x * fl, y * fl}; return {x * value, y * value};
} }
[[nodiscard]] constexpr Vector2 operator/(const float fl) const [[nodiscard]] constexpr Vector2 operator/(const Type& value) const noexcept
{ {
return {x / fl, y / fl}; return {x / value, y / value};
} }
// Sum of elements // Sum of elements
[[nodiscard]] constexpr Type sum() const [[nodiscard]] constexpr Type sum() const noexcept
{ {
return x + y; return x + y;
} }
[[nodiscard]] [[nodiscard]]
constexpr std::tuple<Type, Type> as_tuple() const constexpr std::tuple<Type, Type> as_tuple() const noexcept
{ {
return std::make_tuple(x, y); return std::make_tuple(x, y);
} }
#ifdef OMATH_IMGUI_INTEGRATION #ifdef OMATH_IMGUI_INTEGRATION
[[nodiscard]] [[nodiscard]]
ImVec2 to_im_vec2() const ImVec2 to_im_vec2() const noexcept
{ {
return {static_cast<float>(this->x), static_cast<float>(this->y)}; return {static_cast<float>(this->x), static_cast<float>(this->y)};
} }

View File

@@ -24,86 +24,86 @@ namespace omath
{ {
public: public:
Type z = static_cast<Type>(0); Type z = static_cast<Type>(0);
constexpr Vector3(const Type& x, const Type& y, const Type& z): Vector2<Type>(x, y), z(z) constexpr Vector3(const Type& x, const Type& y, const Type& z) noexcept: Vector2<Type>(x, y), z(z)
{ {
} }
constexpr Vector3(): Vector2<Type>() {}; constexpr Vector3() noexcept: Vector2<Type>() {};
[[nodiscard]] constexpr bool operator==(const Vector3& src) const [[nodiscard]] constexpr bool operator==(const Vector3& other) const noexcept
{ {
return Vector2<Type>::operator==(src) && (src.z == z); return Vector2<Type>::operator==(other) && (other.z == z);
} }
[[nodiscard]] constexpr bool operator!=(const Vector3& src) const [[nodiscard]] constexpr bool operator!=(const Vector3& other) const noexcept
{ {
return !(*this == src); return !(*this == other);
} }
constexpr Vector3& operator+=(const Vector3& v) constexpr Vector3& operator+=(const Vector3& other) noexcept
{ {
Vector2<Type>::operator+=(v); Vector2<Type>::operator+=(other);
z += v.z; z += other.z;
return *this; return *this;
} }
constexpr Vector3& operator-=(const Vector3& v) constexpr Vector3& operator-=(const Vector3& other) noexcept
{ {
Vector2<Type>::operator-=(v); Vector2<Type>::operator-=(other);
z -= v.z; z -= other.z;
return *this; return *this;
} }
constexpr Vector3& operator*=(const float fl) constexpr Vector3& operator*=(const Type& value) noexcept
{ {
Vector2<Type>::operator*=(fl); Vector2<Type>::operator*=(value);
z *= fl; z *= value;
return *this; return *this;
} }
constexpr Vector3& operator*=(const Vector3& v) constexpr Vector3& operator*=(const Vector3& other) noexcept
{ {
Vector2<Type>::operator*=(v); Vector2<Type>::operator*=(other);
z *= v.z; z *= other.z;
return *this; return *this;
} }
constexpr Vector3& operator/=(const Vector3& v) constexpr Vector3& operator/=(const Vector3& other) noexcept
{ {
Vector2<Type>::operator/=(v); Vector2<Type>::operator/=(other);
z /= v.z; z /= other.z;
return *this; return *this;
} }
constexpr Vector3& operator+=(const float fl) constexpr Vector3& operator+=(const Type& value) noexcept
{ {
Vector2<Type>::operator+=(fl); Vector2<Type>::operator+=(value);
z += fl; z += value;
return *this; return *this;
} }
constexpr Vector3& operator/=(const float fl) constexpr Vector3& operator/=(const Type& value) noexcept
{ {
Vector2<Type>::operator/=(fl); Vector2<Type>::operator/=(value);
z /= fl; z /= value;
return *this; return *this;
} }
constexpr Vector3& operator-=(const float fl) constexpr Vector3& operator-=(const Type& value) noexcept
{ {
Vector2<Type>::operator-=(fl); Vector2<Type>::operator-=(value);
z -= fl; z -= value;
return *this; return *this;
} }
constexpr Vector3& abs() constexpr Vector3& abs() noexcept
{ {
Vector2<Type>::abs(); Vector2<Type>::abs();
z = z < 0.f ? -z : z; z = z < 0.f ? -z : z;
@@ -111,12 +111,12 @@ namespace omath
return *this; return *this;
} }
[[nodiscard]] constexpr Type distance_to_sqr(const Vector3& other) const [[nodiscard]] constexpr Type distance_to_sqr(const Vector3& other) const noexcept
{ {
return (*this - other).length_sqr(); return (*this - other).length_sqr();
} }
[[nodiscard]] constexpr Type dot(const Vector3& other) const [[nodiscard]] constexpr Type dot(const Vector3& other) const noexcept
{ {
return Vector2<Type>::dot(other) + z * other.z; return Vector2<Type>::dot(other) + z * other.z;
} }
@@ -142,80 +142,82 @@ namespace omath
return length_value != 0 ? *this / length_value : *this; return length_value != 0 ? *this / length_value : *this;
} }
#else #else
[[nodiscard]] Type length() const [[nodiscard]] Type length() const noexcept
{ {
return std::hypot(this->x, this->y, z); return std::hypot(this->x, this->y, z);
} }
[[nodiscard]] Vector3 normalized() const [[nodiscard]] Vector3 normalized() const noexcept
{ {
const Type len = this->length(); const Type len = this->length();
return len != 0 ? *this / len : *this; return len != 0 ? *this / len : *this;
} }
[[nodiscard]] Type length_2d() const [[nodiscard]] Type length_2d() const noexcept
{ {
return Vector2<Type>::length(); return Vector2<Type>::length();
} }
[[nodiscard]] Type distance_to(const Vector3& vOther) const [[nodiscard]] Type distance_to(const Vector3& vOther) const noexcept
{ {
return (*this - vOther).length(); return (*this - vOther).length();
} }
#endif #endif
[[nodiscard]] constexpr Type length_sqr() const [[nodiscard]] constexpr Type length_sqr() const noexcept
{ {
return Vector2<Type>::length_sqr() + z * z; return Vector2<Type>::length_sqr() + z * z;
} }
[[nodiscard]] constexpr Vector3 operator-() const [[nodiscard]] constexpr Vector3 operator-() const noexcept
{ {
return {-this->x, -this->y, -z}; return {-this->x, -this->y, -z};
} }
[[nodiscard]] constexpr Vector3 operator+(const Vector3& v) const [[nodiscard]] constexpr Vector3 operator+(const Vector3& other) const noexcept
{ {
return {this->x + v.x, this->y + v.y, z + v.z}; return {this->x + other.x, this->y + other.y, z + other.z};
} }
[[nodiscard]] constexpr Vector3 operator-(const Vector3& v) const [[nodiscard]] constexpr Vector3 operator-(const Vector3& other) const noexcept
{ {
return {this->x - v.x, this->y - v.y, z - v.z}; return {this->x - other.x, this->y - other.y, z - other.z};
} }
[[nodiscard]] constexpr Vector3 operator*(const float fl) const [[nodiscard]] constexpr Vector3 operator*(const Type& value) const noexcept
{ {
return {this->x * fl, this->y * fl, z * fl}; return {this->x * value, this->y * value, z * value};
} }
[[nodiscard]] constexpr Vector3 operator*(const Vector3& v) const [[nodiscard]] constexpr Vector3 operator*(const Vector3& other) const noexcept
{ {
return {this->x * v.x, this->y * v.y, z * v.z}; return {this->x * other.x, this->y * other.y, z * other.z};
} }
[[nodiscard]] constexpr Vector3 operator/(const float fl) const [[nodiscard]] constexpr Vector3 operator/(const Type& value) const noexcept
{ {
return {this->x / fl, this->y / fl, z / fl}; return {this->x / value, this->y / value, z / value};
} }
[[nodiscard]] constexpr Vector3 operator/(const Vector3& v) const [[nodiscard]] constexpr Vector3 operator/(const Vector3& other) const noexcept
{ {
return {this->x / v.x, this->y / v.y, z / v.z}; return {this->x / other.x, this->y / other.y, z / other.z};
} }
[[nodiscard]] constexpr Vector3 cross(const Vector3& v) const [[nodiscard]] constexpr Vector3 cross(const Vector3& other) const noexcept
{ {
return {this->y * v.z - z * v.y, z * v.x - this->x * v.z, this->x * v.y - this->y * v.x}; return {this->y * other.z - z * other.y, z * other.x - this->x * other.z,
this->x * other.y - this->y * other.x};
} }
[[nodiscard]] constexpr Type sum() const
[[nodiscard]] constexpr Type sum() const noexcept
{ {
return sum_2d() + z; return sum_2d() + z;
} }
[[nodiscard]] std::expected<Angle<float, 0.f, 180.f, AngleFlags::Clamped>, Vector3Error> [[nodiscard]] std::expected<Angle<float, 0.f, 180.f, AngleFlags::Clamped>, Vector3Error>
angle_between(const Vector3& other) const angle_between(const Vector3& other) const noexcept
{ {
const auto bottom = length() * other.length(); const auto bottom = length() * other.length();
@@ -225,7 +227,7 @@ namespace omath
return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::from_radians(std::acos(dot(other) / bottom)); return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::from_radians(std::acos(dot(other) / bottom));
} }
[[nodiscard]] bool is_perpendicular(const Vector3& other) const [[nodiscard]] bool is_perpendicular(const Vector3& other) const noexcept
{ {
if (const auto angle = angle_between(other)) if (const auto angle = angle_between(other))
return angle->as_degrees() == 90.f; return angle->as_degrees() == 90.f;
@@ -233,19 +235,19 @@ namespace omath
return false; return false;
} }
[[nodiscard]] constexpr Type sum_2d() const [[nodiscard]] constexpr Type sum_2d() const noexcept
{ {
return Vector2<Type>::sum(); return Vector2<Type>::sum();
} }
[[nodiscard]] constexpr std::tuple<Type, Type, Type> as_tuple() const [[nodiscard]] constexpr std::tuple<Type, Type, Type> as_tuple() const noexcept
{ {
return std::make_tuple(this->x, this->y, z); return std::make_tuple(this->x, this->y, z);
} }
[[nodiscard]] Vector3 view_angle_to(const Vector3& other) const [[nodiscard]] Vector3 view_angle_to(const Vector3& other) const noexcept
{ {
const float distance = distance_to(other); const auto distance = distance_to(other);
const auto delta = other - *this; const auto delta = other - *this;
return {angles::radians_to_degrees(std::asin(delta.z / distance)), return {angles::radians_to_degrees(std::asin(delta.z / distance)),

View File

@@ -9,6 +9,7 @@
namespace omath namespace omath
{ {
template<class Type> template<class Type>
requires std::is_arithmetic_v<Type>
class Vector4 : public Vector3<Type> class Vector4 : public Vector3<Type>
{ {
public: public:
@@ -17,90 +18,90 @@ namespace omath
constexpr Vector4(const Type& x, const Type& y, const Type& z, const Type& w): Vector3<Type>(x, y, z), w(w) constexpr Vector4(const Type& x, const Type& y, const Type& z, const Type& w): Vector3<Type>(x, y, z), w(w)
{ {
} }
constexpr Vector4(): Vector3<Type>(), w(0) {}; constexpr Vector4() noexcept : Vector3<Type>(), w(0) {};
[[nodiscard]] [[nodiscard]]
constexpr bool operator==(const Vector4& src) const constexpr bool operator==(const Vector4& other) const noexcept
{ {
return Vector3<Type>::operator==(src) && w == src.w; return Vector3<Type>::operator==(other) && w == other.w;
} }
[[nodiscard]] [[nodiscard]]
constexpr bool operator!=(const Vector4& src) const constexpr bool operator!=(const Vector4& other) const noexcept
{ {
return !(*this == src); return !(*this == other);
} }
constexpr Vector4& operator+=(const Vector4& v) constexpr Vector4& operator+=(const Vector4& other) noexcept
{ {
Vector3<Type>::operator+=(v); Vector3<Type>::operator+=(other);
w += v.w; w += other.w;
return *this; return *this;
} }
constexpr Vector4& operator-=(const Vector4& v) constexpr Vector4& operator-=(const Vector4& other) noexcept
{ {
Vector3<Type>::operator-=(v); Vector3<Type>::operator-=(other);
w -= v.w; w -= other.w;
return *this; return *this;
} }
constexpr Vector4& operator*=(const float scalar) constexpr Vector4& operator*=(const Type& value) noexcept
{ {
Vector3<Type>::operator*=(scalar); Vector3<Type>::operator*=(value);
w *= scalar; w *= value;
return *this; return *this;
} }
constexpr Vector4& operator*=(const Vector4& v) constexpr Vector4& operator*=(const Vector4& other) noexcept
{ {
Vector3<Type>::operator*=(v); Vector3<Type>::operator*=(other);
w *= v.w; w *= other.w;
return *this; return *this;
} }
constexpr Vector4& operator/=(const float scalar) constexpr Vector4& operator/=(const Type& value) noexcept
{ {
Vector3<Type>::operator/=(scalar); Vector3<Type>::operator/=(value);
w /= scalar; w /= value;
return *this; return *this;
} }
constexpr Vector4& operator/=(const Vector4& v) constexpr Vector4& operator/=(const Vector4& other) noexcept
{ {
Vector3<Type>::operator/=(v); Vector3<Type>::operator/=(other);
w /= v.w; w /= other.w;
return *this; return *this;
} }
[[nodiscard]] constexpr Type length_sqr() const [[nodiscard]] constexpr Type length_sqr() const noexcept
{ {
return Vector3<Type>::length_sqr() + w * w; return Vector3<Type>::length_sqr() + w * w;
} }
[[nodiscard]] constexpr Type dot(const Vector4& other) const [[nodiscard]] constexpr Type dot(const Vector4& other) const noexcept
{ {
return Vector3<Type>::dot(other) + w * other.w; return Vector3<Type>::dot(other) + w * other.w;
} }
[[nodiscard]] Vector3<Type> length() const [[nodiscard]] Vector3<Type> length() const noexcept
{ {
return std::sqrt(length_sqr()); return std::sqrt(length_sqr());
} }
constexpr Vector4& abs() constexpr Vector4& abs() noexcept
{ {
Vector3<Type>::abs(); Vector3<Type>::abs();
w = w < 0.f ? -w : w; w = w < 0.f ? -w : w;
return *this; return *this;
} }
constexpr Vector4& clamp(const Type& min, const Type& max) constexpr Vector4& clamp(const Type& min, const Type& max) noexcept
{ {
this->x = std::clamp(this->x, min, max); this->x = std::clamp(this->x, min, max);
this->y = std::clamp(this->y, min, max); this->y = std::clamp(this->y, min, max);
@@ -110,56 +111,56 @@ namespace omath
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator-() const constexpr Vector4 operator-() const noexcept
{ {
return {-this->x, -this->y, -this->z, -w}; return {-this->x, -this->y, -this->z, -w};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator+(const Vector4& v) const constexpr Vector4 operator+(const Vector4& other) const noexcept
{ {
return {this->x + v.x, this->y + v.y, this->z + v.z, w + v.w}; return {this->x + other.x, this->y + other.y, this->z + other.z, w + other.w};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator-(const Vector4& v) const constexpr Vector4 operator-(const Vector4& other) const noexcept
{ {
return {this->x - v.x, this->y - v.y, this->z - v.z, w - v.w}; return {this->x - other.x, this->y - other.y, this->z - other.z, w - other.w};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator*(const Type& scalar) const constexpr Vector4 operator*(const Type& value) const noexcept
{ {
return {this->x * scalar, this->y * scalar, this->z * scalar, w * scalar}; return {this->x * value, this->y * value, this->z * value, w * value};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator*(const Vector4& v) const constexpr Vector4 operator*(const Vector4& other) const noexcept
{ {
return {this->x * v.x, this->y * v.y, this->z * v.z, w * v.w}; return {this->x * other.x, this->y * other.y, this->z * other.z, w * other.w};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator/(const Type& scalar) const constexpr Vector4 operator/(const Type& value) const noexcept
{ {
return {this->x / scalar, this->y / scalar, this->z / scalar, w / scalar}; return {this->x / value, this->y / value, this->z / value, w / value};
} }
[[nodiscard]] [[nodiscard]]
constexpr Vector4 operator/(const Vector4& v) const constexpr Vector4 operator/(const Vector4& other) const noexcept
{ {
return {this->x / v.x, this->y / v.y, this->z / v.z, w / v.w}; return {this->x / other.x, this->y / other.y, this->z / other.z, w / other.w};
} }
[[nodiscard]] [[nodiscard]]
constexpr Type sum() const constexpr Type sum() const noexcept
{ {
return Vector3<Type>::sum() + w; return Vector3<Type>::sum() + w;
} }
#ifdef OMATH_IMGUI_INTEGRATION #ifdef OMATH_IMGUI_INTEGRATION
[[nodiscard]] [[nodiscard]]
ImVec4 to_im_vec4() const ImVec4 to_im_vec4() const noexcept
{ {
return { return {
static_cast<float>(this->x), static_cast<float>(this->x),

View File

@@ -7,7 +7,7 @@ namespace omath::primitives
{ {
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom, std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
const Vector3<float>& dir_forward, const Vector3<float>& dir_forward,
const Vector3<float>& dir_right, const float ratio) const Vector3<float>& dir_right, const float ratio) noexcept
{ {
const auto height = top.distance_to(bottom); const auto height = top.distance_to(bottom);
const auto side_size = height / ratio; const auto side_size = height / ratio;

View File

@@ -5,21 +5,21 @@
namespace omath::collision namespace omath::collision
{ {
bool LineTracer::can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle) bool LineTracer::can_trace_line(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept
{ {
return get_ray_hit_point(ray, triangle) == ray.end; return get_ray_hit_point(ray, triangle) == ray.end;
} }
Vector3<float> Ray::direction_vector() const Vector3<float> Ray::direction_vector() const noexcept
{ {
return end - start; return end - start;
} }
Vector3<float> Ray::direction_vector_normalized() const Vector3<float> Ray::direction_vector_normalized() const noexcept
{ {
return direction_vector().normalized(); return direction_vector().normalized();
} }
Vector3<float> LineTracer::get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) Vector3<float> LineTracer::get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept
{ {
constexpr float k_epsilon = std::numeric_limits<float>::epsilon(); constexpr float k_epsilon = std::numeric_limits<float>::epsilon();

View File

@@ -1,12 +0,0 @@
//
// Created by vlad on 2/4/24.
//
#include "omath/color.hpp"
#include <algorithm>
#include <cmath>
namespace omath
{
}

View File

@@ -21,11 +21,11 @@ namespace omath::iw_engine
m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x)); m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x));
m_view_angles.roll = RollAngle::from_radians(0.f); m_view_angles.roll = RollAngle::from_radians(0.f);
} }
Mat4X4 Camera::calc_view_matrix() const Mat4X4 Camera::calc_view_matrix() const noexcept
{ {
return iw_engine::calc_view_matrix(m_view_angles, m_origin); return iw_engine::calc_view_matrix(m_view_angles, m_origin);
} }
Mat4X4 Camera::calc_projection_matrix() const Mat4X4 Camera::calc_projection_matrix() const noexcept
{ {
return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(),
m_near_plane_distance, m_far_plane_distance); m_near_plane_distance, m_far_plane_distance);

View File

@@ -6,37 +6,37 @@
namespace omath::iw_engine namespace omath::iw_engine
{ {
Vector3<float> forward_vector(const ViewAngles& angles) Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
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> right_vector(const ViewAngles& angles) Vector3<float> right_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
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> up_vector(const ViewAngles& angles) Vector3<float> up_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
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 rotation_matrix(const ViewAngles& angles) Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{ {
return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll); return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll);
} }
Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{ {
return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin); return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin);
} }
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
const float far) const float far) noexcept
{ {
// NOTE: Need magic number to fix fov calculation, since IW engine inherit Quake proj matrix calculation // NOTE: Need magic number to fix fov calculation, since IW engine inherit Quake proj matrix calculation
constexpr auto k_multiply_factor = 0.75f; constexpr auto k_multiply_factor = 0.75f;

View File

@@ -21,11 +21,11 @@ namespace omath::opengl_engine
m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x)); m_view_angles.yaw = -YawAngle::from_radians(std::atan2(delta.y, delta.x));
m_view_angles.roll = RollAngle::from_radians(0.f); m_view_angles.roll = RollAngle::from_radians(0.f);
} }
Mat4X4 Camera::calc_view_matrix() const Mat4X4 Camera::calc_view_matrix() const noexcept
{ {
return opengl_engine::calc_view_matrix(m_view_angles, m_origin); return opengl_engine::calc_view_matrix(m_view_angles, m_origin);
} }
Mat4X4 Camera::calc_projection_matrix() const Mat4X4 Camera::calc_projection_matrix() const noexcept
{ {
return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(),
m_near_plane_distance, m_far_plane_distance); m_near_plane_distance, m_far_plane_distance);

View File

@@ -6,39 +6,39 @@
namespace omath::opengl_engine namespace omath::opengl_engine
{ {
Vector3<float> forward_vector(const ViewAngles& angles) Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{ {
const auto vec const auto vec
= rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_forward); = rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_forward);
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> right_vector(const ViewAngles& angles) Vector3<float> right_vector(const ViewAngles& angles) noexcept
{ {
const auto vec const auto vec
= rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_right); = rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_right);
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> up_vector(const ViewAngles& angles) Vector3<float> up_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_up); const auto vec = rotation_matrix(angles) * mat_column_from_vector<float, MatStoreType::COLUMN_MAJOR>(k_abs_up);
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 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{ {
return mat_camera_view<float, MatStoreType::COLUMN_MAJOR>(-forward_vector(angles), right_vector(angles), return mat_camera_view<float, MatStoreType::COLUMN_MAJOR>(-forward_vector(angles), right_vector(angles),
up_vector(angles), cam_origin); up_vector(angles), cam_origin);
} }
Mat4X4 rotation_matrix(const ViewAngles& angles) Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{ {
return mat_rotation_axis_x<float, MatStoreType::COLUMN_MAJOR>(-angles.pitch) return mat_rotation_axis_x<float, MatStoreType::COLUMN_MAJOR>(-angles.pitch)
* mat_rotation_axis_y<float, MatStoreType::COLUMN_MAJOR>(-angles.yaw) * mat_rotation_axis_y<float, MatStoreType::COLUMN_MAJOR>(-angles.yaw)
* mat_rotation_axis_z<float, MatStoreType::COLUMN_MAJOR>(angles.roll); * mat_rotation_axis_z<float, MatStoreType::COLUMN_MAJOR>(angles.roll);
} }
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
const float far) const float far) noexcept
{ {
const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f); const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f);

View File

@@ -22,12 +22,12 @@ namespace omath::source_engine
m_view_angles.roll = RollAngle::from_radians(0.f); m_view_angles.roll = RollAngle::from_radians(0.f);
} }
Mat4X4 Camera::calc_view_matrix() const Mat4X4 Camera::calc_view_matrix() const noexcept
{ {
return source_engine::calc_view_matrix(m_view_angles, m_origin); return source_engine::calc_view_matrix(m_view_angles, m_origin);
} }
Mat4X4 Camera::calc_projection_matrix() const Mat4X4 Camera::calc_projection_matrix() const noexcept
{ {
return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(),
m_near_plane_distance, m_far_plane_distance); m_near_plane_distance, m_far_plane_distance);

View File

@@ -5,38 +5,38 @@
namespace omath::source_engine namespace omath::source_engine
{ {
Vector3<float> forward_vector(const ViewAngles& angles) Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
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 rotation_matrix(const ViewAngles& angles) Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{ {
return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll); return mat_rotation_axis_z(angles.yaw) * mat_rotation_axis_y(angles.pitch) * mat_rotation_axis_x(angles.roll);
} }
Vector3<float> right_vector(const ViewAngles& angles) Vector3<float> right_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
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> up_vector(const ViewAngles& angles) Vector3<float> up_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
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 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{ {
return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin); return mat_camera_view(forward_vector(angles), right_vector(angles), up_vector(angles), cam_origin);
} }
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
const float far) const float far) noexcept
{ {
// NOTE: Need magic number to fix fov calculation, since source inherit Quake proj matrix calculation // NOTE: Need magic number to fix fov calculation, since source inherit Quake proj matrix calculation
constexpr auto k_multiply_factor = 0.75f; constexpr auto k_multiply_factor = 0.75f;

View File

@@ -15,11 +15,11 @@ namespace omath::unity_engine
{ {
throw std::runtime_error("Not implemented"); throw std::runtime_error("Not implemented");
} }
Mat4X4 Camera::calc_view_matrix() const Mat4X4 Camera::calc_view_matrix() const noexcept
{ {
return unity_engine::calc_view_matrix(m_view_angles, m_origin); return unity_engine::calc_view_matrix(m_view_angles, m_origin);
} }
Mat4X4 Camera::calc_projection_matrix() const Mat4X4 Camera::calc_projection_matrix() const noexcept
{ {
return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(), return calc_perspective_projection_matrix(m_field_of_view.as_degrees(), m_view_port.aspect_ratio(),
m_near_plane_distance, m_far_plane_distance); m_near_plane_distance, m_far_plane_distance);

View File

@@ -5,37 +5,37 @@
namespace omath::unity_engine namespace omath::unity_engine
{ {
Vector3<float> forward_vector(const ViewAngles& angles) Vector3<float> forward_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_forward);
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> right_vector(const ViewAngles& angles) Vector3<float> right_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_right);
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> up_vector(const ViewAngles& angles) Vector3<float> up_vector(const ViewAngles& angles) noexcept
{ {
const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up); const auto vec = rotation_matrix(angles) * mat_column_from_vector(k_abs_up);
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 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) Mat4X4 calc_view_matrix(const ViewAngles& angles, const Vector3<float>& cam_origin) noexcept
{ {
return mat_camera_view<float, MatStoreType::ROW_MAJOR>(forward_vector(angles), -right_vector(angles), return mat_camera_view<float, MatStoreType::ROW_MAJOR>(forward_vector(angles), -right_vector(angles),
up_vector(angles), cam_origin); up_vector(angles), cam_origin);
} }
Mat4X4 rotation_matrix(const ViewAngles& angles) Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept
{ {
return mat_rotation_axis_x<float, MatStoreType::ROW_MAJOR>(angles.pitch) return mat_rotation_axis_x<float, MatStoreType::ROW_MAJOR>(angles.pitch)
* mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw) * mat_rotation_axis_y<float, MatStoreType::ROW_MAJOR>(angles.yaw)
* mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.roll); * mat_rotation_axis_z<float, MatStoreType::ROW_MAJOR>(angles.roll);
} }
Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near, Mat4X4 calc_perspective_projection_matrix(const float field_of_view, const float aspect_ratio, const float near,
const float far) const float far) noexcept
{ {
const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f); const float fov_half_tan = std::tan(angles::degrees_to_radians(field_of_view) / 2.f);

View File

@@ -17,7 +17,7 @@ namespace omath::pathfinding
std::vector<Vector3<float>> std::vector<Vector3<float>>
Astar::reconstruct_final_path(const std::unordered_map<Vector3<float>, PathNode>& closed_list, Astar::reconstruct_final_path(const std::unordered_map<Vector3<float>, PathNode>& closed_list,
const Vector3<float>& current) const Vector3<float>& current) noexcept
{ {
std::vector<Vector3<float>> path; std::vector<Vector3<float>> path;
std::optional current_opt = current; std::optional current_opt = current;
@@ -38,7 +38,7 @@ namespace omath::pathfinding
return path; return path;
} }
auto Astar::get_perfect_node(const std::unordered_map<Vector3<float>, PathNode>& open_list, auto Astar::get_perfect_node(const std::unordered_map<Vector3<float>, PathNode>& open_list,
const Vector3<float>& end_vertex) const Vector3<float>& end_vertex) noexcept
{ {
return std::ranges::min_element(open_list, return std::ranges::min_element(open_list,
[&end_vertex](const auto& a, const auto& b) [&end_vertex](const auto& a, const auto& b)
@@ -50,7 +50,7 @@ namespace omath::pathfinding
} }
std::vector<Vector3<float>> Astar::find_path(const Vector3<float>& start, const Vector3<float>& end, std::vector<Vector3<float>> Astar::find_path(const Vector3<float>& start, const Vector3<float>& end,
const NavigationMesh& nav_mesh) const NavigationMesh& nav_mesh) noexcept
{ {
std::unordered_map<Vector3<float>, PathNode> closed_list; std::unordered_map<Vector3<float>, PathNode> closed_list;
std::unordered_map<Vector3<float>, PathNode> open_list; std::unordered_map<Vector3<float>, PathNode> open_list;

View File

@@ -6,7 +6,8 @@
#include <stdexcept> #include <stdexcept>
namespace omath::pathfinding namespace omath::pathfinding
{ {
std::expected<Vector3<float>, std::string> NavigationMesh::get_closest_vertex(const Vector3<float>& point) const std::expected<Vector3<float>, std::string>
NavigationMesh::get_closest_vertex(const Vector3<float>& point) const noexcept
{ {
const auto res = std::ranges::min_element(m_vertex_map, [&point](const auto& a, const auto& b) const auto res = std::ranges::min_element(m_vertex_map, [&point](const auto& a, const auto& b)
{ return a.first.distance_to(point) < b.first.distance_to(point); }); { return a.first.distance_to(point) < b.first.distance_to(point); });
@@ -17,7 +18,7 @@ namespace omath::pathfinding
return res->first; return res->first;
} }
const std::vector<Vector3<float>>& NavigationMesh::get_neighbors(const Vector3<float>& vertex) const const std::vector<Vector3<float>>& NavigationMesh::get_neighbors(const Vector3<float>& vertex) const noexcept
{ {
return m_vertex_map.at(vertex); return m_vertex_map.at(vertex);
} }
@@ -27,7 +28,7 @@ namespace omath::pathfinding
return m_vertex_map.empty(); return m_vertex_map.empty();
} }
std::vector<uint8_t> NavigationMesh::serialize() const std::vector<uint8_t> NavigationMesh::serialize() const noexcept
{ {
auto dump_to_vector = []<typename T>(const T& t, std::vector<uint8_t>& vec) auto dump_to_vector = []<typename T>(const T& t, std::vector<uint8_t>& vec)
{ {
@@ -50,7 +51,7 @@ namespace omath::pathfinding
return raw; return raw;
} }
void NavigationMesh::deserialize(const std::vector<uint8_t>& raw) void NavigationMesh::deserialize(const std::vector<uint8_t>& raw) noexcept
{ {
auto load_from_vector = [](const std::vector<uint8_t>& vec, size_t& offset, auto& value) auto load_from_vector = [](const std::vector<uint8_t>& vec, size_t& offset, auto& value)
{ {

View File

@@ -1,9 +0,0 @@
//
// Created by Vlad on 2/23/2025.
//
#include "omath/projectile_prediction/proj_pred_engine.hpp"
namespace omath::projectile_prediction
{
} // namespace omath::projectile_prediction

View File

@@ -18,8 +18,8 @@ namespace omath::projectile_prediction
{ {
const auto predicted_target_position = target.predict_position(time, m_gravity_constant); const auto predicted_target_position = target.predict_position(time, m_gravity_constant);
const auto projectile_pitch const auto projectile_pitch =
= maybe_calculate_projectile_launch_pitch_angle(projectile, predicted_target_position); maybe_calculate_projectile_launch_pitch_angle(projectile, predicted_target_position);
if (!projectile_pitch.has_value()) [[unlikely]] if (!projectile_pitch.has_value()) [[unlikely]]
continue; continue;
@@ -35,9 +35,8 @@ namespace omath::projectile_prediction
return std::nullopt; return std::nullopt;
} }
std::optional<float> std::optional<float> ProjPredEngineLegacy::maybe_calculate_projectile_launch_pitch_angle(
ProjPredEngineLegacy::maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile, const Projectile& projectile, const Vector3<float>& target_position) const noexcept
const Vector3<float>& target_position) const
{ {
const auto bullet_gravity = m_gravity_constant * projectile.m_gravity_scale; const auto bullet_gravity = m_gravity_constant * projectile.m_gravity_scale;
const auto delta = target_position - projectile.m_origin; const auto delta = target_position - projectile.m_origin;
@@ -60,7 +59,7 @@ namespace omath::projectile_prediction
bool ProjPredEngineLegacy::is_projectile_reached_target(const Vector3<float>& target_position, bool ProjPredEngineLegacy::is_projectile_reached_target(const Vector3<float>& target_position,
const Projectile& projectile, const float pitch, const Projectile& projectile, const float pitch,
const float time) const const float time) const noexcept
{ {
const auto yaw = projectile.m_origin.view_angle_to(target_position).y; const auto yaw = projectile.m_origin.view_angle_to(target_position).y;
const auto projectile_position = projectile.predict_position(pitch, yaw, time, m_gravity_constant); const auto projectile_position = projectile.predict_position(pitch, yaw, time, m_gravity_constant);

View File

@@ -8,7 +8,7 @@
namespace omath::projectile_prediction namespace omath::projectile_prediction
{ {
Vector3<float> Projectile::predict_position(const float pitch, const float yaw, const float time, Vector3<float> Projectile::predict_position(const float pitch, const float yaw, const float time,
const float gravity) const const float gravity) const noexcept
{ {
auto current_pos = m_origin auto current_pos = m_origin
+ source_engine::forward_vector({source_engine::PitchAngle::from_degrees(-pitch), + source_engine::forward_vector({source_engine::PitchAngle::from_degrees(-pitch),

View File

@@ -1,10 +0,0 @@
//
// Created by Vlad on 6/9/2024.
//
#include "omath/projectile_prediction/projectile.hpp"
namespace omath::prediction
{
}

View File

@@ -1,8 +0,0 @@
//
// Created by Vlad on 27.08.2024.
//
#include "omath/projection/camera.hpp"
namespace omath::projection
{
}

7
writerside/c.list Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE categories
SYSTEM "https://resources.jetbrains.com/writerside/1.0/categories.dtd">
<categories>
<category id="wrs" name="Writerside documentation" order="1"/>
<category id="inf" name="Learn more" order="2"/>
</categories>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE buildprofiles SYSTEM "https://resources.jetbrains.com/writerside/1.0/build-profiles.dtd">
<buildprofiles xsi:noNamespaceSchemaLocation="https://resources.jetbrains.com/writerside/1.0/build-profiles.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variables></variables>
<build-profile instance="o">
<variables>
<noindex-content>true</noindex-content>
</variables>
</build-profile>
</buildprofiles>

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

14
writerside/o.tree Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE instance-profile
SYSTEM "https://resources.jetbrains.com/writerside/1.0/product-profile.dtd">
<instance-profile id="o"
name="OMATH"
start-page="starter-topic.md">
<toc-element topic="starter-topic.md"/>
<toc-element topic="Documentation.md"/>
<toc-element topic="Code-Of-Conduct.md"/>
<toc-element topic="Community.md"/>
<toc-element topic="License.md"/>
</instance-profile>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rules SYSTEM "https://resources.jetbrains.com/writerside/1.0/redirection-rules.dtd">
<rules>
<!-- format is as follows
<rule id="<unique id>">
<accepts>page.html</accepts>
</rule>
-->
<rule id="4e037516">
<description><![CDATA[Created after removal of "<Empty-MD-Topic.md>" from OMATH]]></description>
<accepts>Empty-MD-Topic.html</accepts>
</rule>
</rules>

View File

@@ -0,0 +1,95 @@
# Code Of Conduct
## 🎯 Goal
My goal is to provide a space where it is safe for everyone to contribute to,
and get support for, open-source software in a respectful and cooperative
manner.
I value all contributions and want to make this project and its
surrounding community a place for everyone.
As members, contributors, and everyone else who may participate in the
development, I strive to keep the entire experience civil.
## 📜 Standards
Our community standards exist in order to make sure everyone feels comfortable
contributing to the project(s) together.
Our standards are:
- Do not harass, attack, or in any other way discriminate against anyone, including
for their protected traits, including, but not limited to, sex, religion, race,
appearance, gender, identity, nationality, sexuality, etc.
- Do not go off-topic, do not post spam.
- Treat everyone with respect.
Examples of breaking each rule respectively include:
- Harassment, bullying or inappropriate jokes about another person.
- Posting distasteful imagery, trolling, or posting things unrelated to the topic at hand.
- Treating someone as worse because of their lack of understanding of an issue.
## ⚡ Enforcement
Enforcement of this CoC is done by Orange++ and/or other core contributors.
I, as the core developer, will strive my best to keep this community civil and
following the standards outlined above.
### 🚩 Reporting incidents
If you believe an incident of breaking these standards has occurred, but nobody has
taken appropriate action, you can privately contact the people responsible for dealing
with such incidents in multiple ways:
***E-Mail***
- `orange-cpp@yandex.ru`
***Discord***
- `@orange_cpp`
***Telegram***
- `@orange_cpp`
I guarantee your privacy and will not share those reports with anyone.
## ⚖️ Enforcement Strategy
Depending on the severity of the infraction, any action from the list below may be applied.
Please keep in mind cases are reviewed on a per-case basis and members are the ultimate
deciding factor in the type of punishment.
If the matter benefited from an outside opinion, a member might reach for more opinions
from people unrelated, however, the final decision regarding the action
to be taken is still up to the member.
For example, if the matter at hand regards a representative of a marginalized group or minority,
the member might ask for a first-hand opinion from another representative of such group.
### ✏️ Correction/Edit
If your message is found to be misleading or poorly worded, a member might
edit your message.
### ⚠️ Warning/Deletion
If your message is found inappropriate, a member might give you a public or private warning,
and/or delete your message.
### 🔇 Mute
If your message is disruptive, or you have been repeatedly violating the standards,
a member might mute (or temporarily ban) you.
### ⛔ Ban
If your message is hateful, very disruptive, or other, less serious infractions are repeated
ignoring previous punishments, a member might ban you permanently.
## 🔎 Scope
This CoC shall apply to all projects ran under the Orange++ lead and all _official_ communities
outside of GitHub.
However, it is worth noting that official communities outside of GitHub might have their own,
additional sets of rules.

View File

@@ -0,0 +1,11 @@
# Credits
Thanks to everyone who made this possible, including:
- Saikari aka luadebug for VCPKG port.
And a big hand to everyone else who has contributed over the past!
THANKS! <3
-- Orange++ <orange-cpp@yandex.ru>

View File

@@ -0,0 +1,54 @@
# 📥Installation Guide
## Using vcpkg
**Note**: Support vcpkg for package management
1. Install [vcpkg](https://github.com/microsoft/vcpkg)
2. Run the following command to install the orange-math package:
```
vcpkg install orange-math
```
CMakeLists.txt
```cmake
find_package(omath CONFIG REQUIRED)
target_link_libraries(main PRIVATE omath::omath)
```
For detailed commands on installing different versions and more information, please refer to Microsoft's [official instructions](https://learn.microsoft.com/en-us/vcpkg/get_started/overview).
## Build from source using CMake
1. **Preparation**
Install needed tools: cmake, clang, git, msvc (windows only).
1. **Linux:**
```bash
sudo pacman -Sy cmake ninja clang git
```
2. **MacOS:**
```bash
brew install llvm git cmake ninja
```
3. **Windows:**
Install Visual Studio from [here](https://visualstudio.microsoft.com/downloads/) and Git from [here](https://git-scm.com/downloads).
Use x64 Native Tools shell to execute needed commands down below.
2. **Clone the repository:**
```bash
git clone https://github.com/orange-cpp/omath.git
```
3. **Navigate to the project directory:**
```bash
cd omath
```
4. **Build the project using CMake:**
```bash
cmake --preset windows-release -S .
cmake --build cmake-build/build/windows-release --target omath -j 6
```
Use **\<platform\>-\<build configuration\>** preset to build siutable version for yourself. Like **windows-release** or **linux-release**.
| Platform Name | Build Config |
|---------------|---------------|
| windows | release/debug |
| linux | release/debug |
| darwin | release/debug |

View File

@@ -0,0 +1,9 @@
# License
Copyright (c) 2025 Orange++
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,67 @@
# Intro
![banner](https://i.imgur.com/SM9ccP6.png)
Oranges's Math Library (omath) is a comprehensive, open-source library aimed at providing efficient, reliable, and versatile mathematical functions and algorithms. Developed primarily in C++, this library is designed to cater to a wide range of mathematical operations essential in scientific computing, engineering, and academic research.
## 👁‍🗨 Features
- **Efficiency**: Optimized for performance, ensuring quick computations using AVX2.
- **Versatility**: Includes a wide array of mathematical functions and algorithms.
- **Ease of Use**: Simplified interface for convenient integration into various projects.
- **Projectile Prediction**: Projectile prediction engine with O(N) algo complexity, that can power you projectile aim-bot.
- **3D Projection**: No need to find view-projection matrix anymore you can make your own projection pipeline.
- **Collision Detection**: Production ready code to handle collision detection by using simple interfaces.
- **No Additional Dependencies**: No additional dependencies need to use OMath except unit test execution
- **Ready for meta-programming**: Omath use templates for common types like Vectors, Matrixes etc, to handle all types!
## Supported Render Pipelines
| ENGINE | SUPPORT |
|----------|---------|
| Source | ✅YES |
| Unity | ✅YES |
| IWEngine | ✅YES |
| Unreal | ❌NO |
## Supported Operating Systems
| OS | SUPPORT |
|----------------|---------|
| Windows 10/11 | ✅YES |
| Linux | ✅YES |
| Darwin (MacOS) | ✅YES |
## ⏬ Installation
Please read our [installation guide](https://github.com/orange-cpp/omath/blob/main/INSTALL.md). If this link doesn't work check out INSTALL.md file.
## ❔ Usage
Simple world to screen function
```c++
TEST(UnitTestProjection, IsPointOnScreen)
{
const omath::projection::Camera camera({0.f, 0.f, 0.f}, {0, 0.f, 0.f} , {1920.f, 1080.f}, 110.f, 0.1f, 500.f);
const auto proj = camera.WorldToScreen({100, 0, 15});
EXPECT_TRUE(proj.has_value());
}
```
## Showcase
With `omath/projection` module you can achieve simple ESP hack for powered by Source/Unreal/Unity engine games, like [Apex Legends](https://store.steampowered.com/app/1172470/Apex_Legends/).
![banner](https://i.imgur.com/lcJrfcZ.png)
Or for InfinityWard Engine based games. Like Call of Duty Black Ops 2!
![banner](https://i.imgur.com/F8dmdoo.png)
Or create simple trigger bot with embeded traceline from omath::collision::LineTrace
![banner](https://i.imgur.com/fxMjRKo.jpeg)
Or even advanced projectile aimbot
[Watch Video](https://youtu.be/lM_NJ1yCunw?si=5E87OrQMeypxSJ3E)
## 🫵🏻 Contributing
Contributions to `omath` are welcome! Please read `CONTRIBUTING.md` for details on our code of conduct and the process for submitting pull requests.
## 📜 License
This project is licensed under the MIT - see the `LICENSE` file for details.
## 💘 Acknowledgments
- [All contributors](https://github.com/orange-cpp/omath/graphs/contributors)

5
writerside/v.list Normal file
View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vars SYSTEM "https://resources.jetbrains.com/writerside/1.0/vars.dtd">
<vars>
<var name="product" value="Writerside"/>
</vars>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ihp SYSTEM "https://resources.jetbrains.com/writerside/1.0/ihp.dtd">
<ihp version="2.0">
<topics dir="topics" web-path="topics"/>
<images dir="images" web-path="images"/>
<instance src="o.tree"/>
</ihp>