4 #include "../Matrix/MatrixImpl.hpp" 5 #include "../Vector.hpp" 11 template <
class T,
int Dim,
bool Packed>
17 : eye(eye), target(target), bases(bases), flipAxes(flipAxes) {}
20 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
27 template <
class U, eMatrixLayout Layout,
bool MPacked>
34 template <
class U, eMatrixLayout Layout,
bool MPacked>
43 template <
class U,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
46 std::array<
const VectorT*, Dim - 1> crossTable = {};
47 for (
int i = 0; i < (int)bases.size(); ++i) {
48 crossTable[i] = &bases[i];
50 crossTable.back() = &columns[Dim - 1];
51 auto elem = [&matrix](
int i,
int j) -> T& {
64 for (
int s = 0; s < j; ++s) {
65 crossTable[s] = crossTable[s + 1];
67 crossTable[j] = &columns[Dim - j - 2];
71 for (
int i = 0; i < Dim; ++i) {
78 for (
int i = 0; i < Dim; ++i) {
79 for (
int j = 0; j < Dim; ++j) {
80 elem(i, j) = columns[j][i];
85 for (
int j = 0; j < Dim; ++j) {
86 elem(Dim, j) = -
Dot(eye, columns[j]);
90 constexpr
int AuxDim = Rows < Columns ? Rows : Columns;
92 for (
int i = 0; i < Dim; ++i) {
93 elem(i, AuxDim - 1) = 0;
95 elem(Dim, AuxDim - 1) = 1;
101 const std::array<
VectorT, size_t(Dim - 2)> bases;
102 const std::array<bool, Dim> flipAxes;
117 template <
class T,
int Dim,
bool Packed,
size_t BaseDim,
size_t FlipDim>
121 const std::array<bool, FlipDim>& flipAxes) {
122 static_assert(BaseDim == Dim - 2,
"You must provide 2 fewer bases than the dimension of the transform.");
123 static_assert(Dim == FlipDim,
"You must provide the same number of flips as the dimension of the transform.");
133 template <
class T,
bool Packed>
146 template <
class T,
bool Packed>
147 auto LookAt(
const Vector<T, 3, Packed>& eye,
const Vector<T, 3, Packed>& target,
const Vector<T, 3, Packed>& up,
bool positiveZForward =
true,
bool flipX =
false,
bool flipY =
false) {
Definition: ViewBuilder.hpp:12
Quaternion< T, Packed > Normalize(const Quaternion< T, Packed > &q)
Returns the unit quaternion of the same direction. Does not change this object.
Definition: QuaternionFunction.hpp:66
Represents a vector in N-dimensional space.
Definition: Definitions.hpp:57
T Dot(const Vector< T, Dim, Packed > &lhs, const Vector< T, Dim, Packed > &rhs)
Calculates the scalar product (dot product) of the two arguments.
Definition: VectorFunction.hpp:111
Definition: Approx.hpp:11
auto LookAt(const Vector< T, Dim, Packed > &eye, const Vector< T, Dim, Packed > &target, const std::array< Vector< T, Dim, Packed >, BaseDim > &bases, const std::array< bool, FlipDim > &flipAxes)
Creates a camera look-at matrix.
Definition: ViewBuilder.hpp:118
Definition: Definitions.hpp:63
auto Cross(const Vector< T, Dim, Packed > &head, Args &&... args) -> Vector< T, Dim, Packed >
Returns the generalized cross-product in N dimensions.
Definition: VectorFunction.hpp:223
ViewBuilder & operator=(const ViewBuilder &)=delete
ViewBuilder(const VectorT &eye, const VectorT &target, const std::array< VectorT, size_t(Dim - 2)> &bases, const std::array< bool, Dim > &flipAxes)
Definition: ViewBuilder.hpp:16