From a7eacb529e041d6d96c5673a3281d48a3935bd72 Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 23 Oct 2025 00:48:54 +0300 Subject: [PATCH] updated comments --- include/omath/projection/camera.hpp | 42 +++++++++++++++++----------- include/omath/projection/utility.hpp | 5 ++++ 2 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 include/omath/projection/utility.hpp diff --git a/include/omath/projection/camera.hpp b/include/omath/projection/camera.hpp index 05a9c8d..6675297 100644 --- a/include/omath/projection/camera.hpp +++ b/include/omath/projection/camera.hpp @@ -238,10 +238,8 @@ namespace omath::projection return std::ranges::any_of(ndc.raw_array(), [](const auto& val) { return val < -1 || val > 1; }); } - [[nodiscard]] Vector3 - ndc_to_screen_position_from_top_left_corner(const Vector3& ndc) const noexcept - { - /* + // NDC REPRESENTATION: + /* ^ | y 1 | @@ -254,6 +252,20 @@ namespace omath::projection v */ + [[nodiscard]] Vector3 + ndc_to_screen_position_from_top_left_corner(const Vector3& ndc) const noexcept + { + /* + +------------------------> + | (0, 0) + | + | + | + | + | + | + ⌄ + */ return {(ndc.x + 1.f) / 2.f * m_view_port.m_width, (ndc.y / -2.f + 0.5f) * m_view_port.m_height, ndc.z}; } @@ -261,18 +273,16 @@ namespace omath::projection ndc_to_screen_position_from_bottom_left_corner(const Vector3& ndc) const noexcept { /* - ^ - | y - 1 | - | - | - -1 ---------0--------- 1 --> x - | - | - -1 | - v - */ - + ^ + | + | + | + | + | + | + | (0, 0) + +------------------------> + */ return {(ndc.x + 1.f) / 2.f * m_view_port.m_width, (ndc.y / 2.f + 0.5f) * m_view_port.m_height, ndc.z}; } diff --git a/include/omath/projection/utility.hpp b/include/omath/projection/utility.hpp new file mode 100644 index 0000000..ee6b656 --- /dev/null +++ b/include/omath/projection/utility.hpp @@ -0,0 +1,5 @@ +// +// Created by Vlad on 10/23/2025. +// + +#pragma once