Go to the documentation of this file. 1 #ifndef EAGINE_MATH_MATRIX_LOOKING_AT_HPP
9 #define EAGINE_MATH_MATRIX_LOOKING_AT_HPP
11 #include "../quantities.hpp"
18 class looking_at_y_up;
21 template <
typename T,
int N,
bool RM,
bool V>
22 struct is_matrix_constructor<looking_at_y_up<matrix<T, N, N, RM, V>>>
31 template <
typename T,
bool RM,
bool V>
32 class looking_at_y_up<
matrix<T, 4, 4, RM, V>> {
54 _make(
const _dT& x,
const _dT& y,
const _dT& z,
const _dT& t) noexcept {
56 {{x[0], x[1], x[2], -
dot(x, t)},
57 {y[0], y[1], y[2], -
dot(y, t)},
58 {z[0], z[1], z[2], -
dot(z, t)},
59 {T(0), T(0), T(0), T(1)}}};
63 _make(
const _dT& y,
const _dT& z,
const _dT& t) noexcept {
64 return _make(
cross(y, z), y, z, t);
67 static constexpr
auto _make(
const _dT& z,
const _dT& t) noexcept {
71 static constexpr
auto _make(
const _dT& z) noexcept {
72 return _make(z, _dT::make(z.z(), T(0), -z.x()));
75 constexpr
auto _make(std::true_type)
const noexcept {
79 constexpr
auto _make(std::false_type)
const noexcept {
80 return reorder(_make(std::true_type()));
85 template <
typename T,
int N,
bool RM,
bool V>
87 reorder_mat_ctr(
const looking_at_y_up<matrix<T, N, N, RM, V>>& c) noexcept
88 -> looking_at_y_up<matrix<T, N, N, !RM, V>> {
94 template <
typename T,
bool V>
100 #endif // EAGINE_MATH_MATRIX_LOOKING_AT_HPP
static auto normalized(const vector< T, N, V > &a) noexcept
Returns normalized argument.
Definition: vector.hpp:379
static auto reorder(const matrix< T, C, R, RM, V > &m) noexcept -> matrix< T, C, R, !RM, V >
Returns a matrix reordered (switches row/column major).
Definition: matrix.hpp:314
constexpr auto operator()() const noexcept
Returns the constructed matrix.
Definition: matrix_looking_at.hpp:44
std::integral_constant< bool, B > bool_constant
Alias for boolean constant type.
Definition: int_constant.hpp:20
constexpr looking_at_y_up(const vector< T, 3, V > &eye, const vector< T, 3, V > &target) noexcept
Initializes the matrix constructor.
Definition: matrix_looking_at.hpp:37
Math-related code is placed in this namespace.
Definition: eagine.hpp:48
static constexpr auto dot(const vector< T, N, V > &a, const vector< T, N, V > &b) noexcept
Vector dot product.
Definition: vector.hpp:311
Helper class used in matrix constructor implementation.
Definition: matrix_ctr.hpp:74
convertible_matrix_constructor< looking_at_y_up< matrix< T, 4, 4, true, V > >> matrix_looking_at_y_up
Alias for constructor of look-at matrix used for camera transformations.
Definition: matrix_looking_at.hpp:96
static auto cross(const vector< T, 3, V > &a, const vector< T, 3, V > &b) noexcept
3D vector cross product.
Definition: vector.hpp:326
Basic RxC matrix implementation template.
Definition: fwd.hpp:25