From 11d96829b6763799954a66b763d772b8de3b10d0 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 21 Jul 2026 13:21:24 +0300 Subject: [PATCH] Support retrieving linear & affine matrix, translation vector, and affine transform from math::orthographic --- .../math/include/psemek/math/orthographic.hpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libs/math/include/psemek/math/orthographic.hpp b/libs/math/include/psemek/math/orthographic.hpp index 798faefa..e518554b 100644 --- a/libs/math/include/psemek/math/orthographic.hpp +++ b/libs/math/include/psemek/math/orthographic.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace psemek::math { @@ -14,6 +15,8 @@ namespace psemek::math { using vector_type = math::vector; using point_type = math::point; + using affine_matrix_type = math::matrix; + using linear_matrix_type = math::matrix; using homogeneous_matrix_type = math::matrix; using box_type = math::box; @@ -26,8 +29,13 @@ namespace psemek::math vector_type operator() (vector_type v) const; point_type operator() (point_type p) const; + affine_matrix_type affine_matrix() const; + linear_matrix_type linear_matrix() const; + vector_type translation_vector() const; homogeneous_matrix_type homogeneous_matrix() const; + affine_transform transform() const; + orthographic inverse() const; private: @@ -76,6 +84,24 @@ namespace psemek::math return as_point(homogeneous_matrix() * homogeneous(p)); } + template + matrix orthographic::affine_matrix() const + { + return submatrix<0, 0, D, D + 1>(homogeneous_matrix()); + } + + template + matrix orthographic::linear_matrix() const + { + return submatrix<0, 0, D, D>(homogeneous_matrix()); + } + + template + vector orthographic::translation_vector() const + { + return column(affine_matrix(), D); + } + template matrix orthographic::homogeneous_matrix() const { @@ -92,6 +118,12 @@ namespace psemek::math return m; } + template + affine_transform orthographic::transform() const + { + return {affine_matrix()}; + } + template orthographic orthographic::inverse() const {