Support retrieving linear & affine matrix, translation vector, and affine transform from math::orthographic
This commit is contained in:
parent
0236fc97b7
commit
11d96829b6
1 changed files with 32 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include <psemek/math/box.hpp>
|
||||
#include <psemek/math/matrix.hpp>
|
||||
#include <psemek/math/homogeneous.hpp>
|
||||
#include <psemek/math/affine_transform.hpp>
|
||||
|
||||
namespace psemek::math
|
||||
{
|
||||
|
|
@ -14,6 +15,8 @@ namespace psemek::math
|
|||
{
|
||||
using vector_type = math::vector<T, D>;
|
||||
using point_type = math::point<T, D>;
|
||||
using affine_matrix_type = math::matrix<T, D, D + 1>;
|
||||
using linear_matrix_type = math::matrix<T, D, D>;
|
||||
using homogeneous_matrix_type = math::matrix<T, D + 1, D + 1>;
|
||||
using box_type = math::box<T, D>;
|
||||
|
||||
|
|
@ -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<T, D, D> transform() const;
|
||||
|
||||
orthographic inverse() const;
|
||||
|
||||
private:
|
||||
|
|
@ -76,6 +84,24 @@ namespace psemek::math
|
|||
return as_point(homogeneous_matrix() * homogeneous(p));
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
matrix<T, D, D + 1> orthographic<T, D>::affine_matrix() const
|
||||
{
|
||||
return submatrix<0, 0, D, D + 1>(homogeneous_matrix());
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
matrix<T, D, D> orthographic<T, D>::linear_matrix() const
|
||||
{
|
||||
return submatrix<0, 0, D, D>(homogeneous_matrix());
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
vector<T, D> orthographic<T, D>::translation_vector() const
|
||||
{
|
||||
return column(affine_matrix(), D);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
matrix<T, D + 1, D + 1> orthographic<T, D>::homogeneous_matrix() const
|
||||
{
|
||||
|
|
@ -92,6 +118,12 @@ namespace psemek::math
|
|||
return m;
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
affine_transform<T, D, D> orthographic<T, D>::transform() const
|
||||
{
|
||||
return {affine_matrix()};
|
||||
}
|
||||
|
||||
template <typename T, std::size_t D>
|
||||
orthographic<T, D> orthographic<T, D>::inverse() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue