diff --git a/src/core/include/pw/core/matrix.hpp b/src/core/include/pw/core/matrix.hpp index 6588d76..57412ee 100644 --- a/src/core/include/pw/core/matrix.hpp +++ b/src/core/include/pw/core/matrix.hpp @@ -23,6 +23,7 @@ #ifndef PW_CORE_MATRIX_HPP #define PW_CORE_MATRIX_HPP +#include "vector.hpp" #include #include #include @@ -205,6 +206,15 @@ struct matrix final { }(std::make_index_sequence{}); // rowwise expansion } + constexpr auto unproject(const Scalar& w) const noexcept + -> matrix { + return [&w, this](std::index_sequence) { + return matrix{ + (Rs < Rows) ? (*this)[Rs].unproject(0) + : vector::basis(Cols) * w...}; + }(std::make_index_sequence{}); // rowwise expansion + } + // // Iterators // diff --git a/src/core/include/pw/core/point.hpp b/src/core/include/pw/core/point.hpp index 5ce5a9d..b5cdc5d 100644 --- a/src/core/include/pw/core/point.hpp +++ b/src/core/include/pw/core/point.hpp @@ -24,20 +24,11 @@ #define PW_CORE_POINT_HPP #include +#include namespace pw { -template struct point final { - - using value_type = Scalar; - - Scalar x{}, y{}; - - template - constexpr auto cast() const noexcept -> point { - return {.x{ScalarOut(x)}, .y{ScalarOut(y)}}; - } -}; +template using point = vector; } // namespace pw diff --git a/src/core/tests/pwcore_test_matrix.cpp b/src/core/tests/pwcore_test_matrix.cpp index 2a89022..73fa915 100644 --- a/src/core/tests/pwcore_test_matrix.cpp +++ b/src/core/tests/pwcore_test_matrix.cpp @@ -65,4 +65,9 @@ auto main() -> int { // octave/matlab style output std::print("\nm33=[{}]\n", m33); + + auto m44 = m33.unproject(1); + + std::print("\nm44=[{}]\n", m44); + }