3 #include "../Matrix/MatrixFunction.hpp" 4 #include "../Matrix/MatrixImpl.hpp" 5 #include "../Quaternion/QuaternionImpl.hpp" 6 #include "../Vector.hpp" 20 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
27 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
34 template <
class U, eMatrixLayout Layout,
bool MPacked>
41 template <
class U, eMatrixLayout Layout,
bool MPacked>
48 template <
class U,
bool QPacked>
52 template <
class U,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
57 auto elem = [&m](
int i,
int j) -> T& {
61 assert(0 <= axis && axis < 3);
103 for (
int i = (j < 3 ? 3 : 0); i < m.
RowCount(); ++i) {
130 template <
int Axis,
class T>
140 return RotationAxis<0>(angle);
147 return RotationAxis<1>(angle);
154 return RotationAxis<2>(angle);
165 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
172 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
179 template <
class U, eMatrixLayout Layout,
bool MPacked>
186 template <
class U, eMatrixLayout Layout,
bool MPacked>
193 template <
class U,
bool QPacked>
197 template <
class U,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
209 for (
int i = (j < 3 ? 3 : 0); i < m.
RowCount(); ++i) {
215 const std::array<T, 3> angles;
216 const std::array<int, 3> axes;
224 template <
int FirstAxis,
int SecondAxis,
int ThirdAxis,
class T>
226 return Rotation3DTriAxisBuilder(std::array<T, 3>{ angle0, angle1, angle2 }, std::array<int, 3>{ FirstAxis, SecondAxis, ThirdAxis });
235 return RotationAxis3<2, 0, 2>(z1, x2, z3);
244 return RotationAxis3<0, 1, 2>(x1, y2, z3);
249 template <
class T,
bool Packed>
255 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
262 template <
class U, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
269 template <
class U, eMatrixLayout Layout,
bool MPacked>
276 template <
class U, eMatrixLayout Layout,
bool MPacked>
283 template <
class U,
bool QPacked>
287 template <
class U,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool MPacked>
306 auto elem = [&m](
int i,
int j) -> T& {
309 for (
int j = 0; j < 3; ++j) {
310 for (
int i = 0; i < 3; ++i) {
311 elem(i, j) = rot(i, j);
316 for (
int j = 0; j < m.
Width(); ++j) {
317 for (
int i = (j < 3 ? 3 : 0); i < m.
Height(); ++i) {
331 template <
class T,
bool Vpacked,
class U>
339 template <
class T,
int Rows,
int Columns, eMatrixOrder Order, eMatrixLayout Layout,
bool Packed>
341 static_assert(Rows == 3 || Rows == 4);
342 static_assert(Columns == 3 || Columns == 4);
344 { m(0, 0), m(0, 1), m(0, 2) },
345 { m(1, 0), m(1, 1), m(1, 2) },
346 { m(2, 0), m(2, 1), m(2, 2) },
348 return (std::abs(
Dot(rows[0], rows[1])) + std::abs(
Dot(rows[0], rows[2])) + std::abs(
Dot(rows[1], rows[2]))) < T(0.0005)
355 template <
class U,
bool QPacked>
364 throw std::invalid_argument(
"Axis must be 0, 1, or 2.");
368 template <
class U,
bool QPacked>
374 template <
class T,
bool Packed>
375 template <
class U,
bool QPacked>
377 auto halfAngle = U(angle) * U(0.5);
auto Identity()
Creates an identity matrix or identity quaternion.
Definition: IdentityBuilder.hpp:42
bool IsRotationMatrix3D(const Matrix< T, Rows, Columns, Order, Layout, Packed > &m)
Determines if the matrix is a proper rotation matrix.
Definition: Rotation3DBuilder.hpp:340
Allows you to do quaternion math and represent rotation in a compact way.
Definition: Definitions.hpp:69
Matrix< T, Columns, Rows, Order, Layout, Packed > Transpose(const Matrix< T, Rows, Columns, Order, Layout, Packed > &m)
Transposes the matrix in-place.
Definition: MatrixFunction.hpp:34
Rotation3DAxisBuilder(const T &angle, int axis)
Definition: Rotation3DBuilder.hpp:17
Rotation3DTriAxisBuilder(const std::array< T, 3 > &angles, std::array< int, 3 > axes)
Definition: Rotation3DBuilder.hpp:162
auto RotationAxisAngle(const Vector< T, 3, Vpacked > &axis, U angle)
Rotates around an arbitrary axis.
Definition: Rotation3DBuilder.hpp:332
auto RotationY(T angle)
Rotates around the Y axis according to the right (left) hand rule.
Definition: Rotation3DBuilder.hpp:146
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: Rotation3DBuilder.hpp:15
auto RotationRPY(T x1, T y2, T z3)
Rotation matrix from roll-pitch-yaw angles. Rotations are X-Y-Z.
Definition: Rotation3DBuilder.hpp:243
Definition: Approx.hpp:11
Rotation3DAxisBuilder & operator=(const Rotation3DAxisBuilder &)=delete
Definition: Rotation3DBuilder.hpp:250
auto RotationAxis(T angle, int axis)
Rotates around coordinate axis.
Definition: Rotation3DBuilder.hpp:121
constexpr int Height() const
Returns the number of rows of the matrix.
Definition: MatrixImpl.hpp:39
auto RotationEuler(T z1, T x2, T z3)
Rotation matrix from Euler angles. Rotations are Z-X-Z.
Definition: Rotation3DBuilder.hpp:234
constexpr int ColumnCount() const
Returns the number of columns of the matrix.
Definition: MatrixImpl.hpp:27
Definition: Definitions.hpp:63
constexpr int Width() const
Returns the number of columns of the matrix.
Definition: MatrixImpl.hpp:35
Definition: Rotation3DBuilder.hpp:160
auto RotationX(T angle)
Rotates around the X axis according to the right (left) hand rule.
Definition: Rotation3DBuilder.hpp:139
Rotation3DAxisAngleBuilder(const Vector< T, 3, Packed > &axis, T angle)
Definition: Rotation3DBuilder.hpp:252
T Determinant(const Matrix< T, Dim, Dim, Order, Layout, Packed > &m)
Returns the determinant of the matrix.
Definition: MatrixFunction.hpp:21
auto RotationZ(T angle)
Rotates around the Z axis according to the right (left) hand rule.
Definition: Rotation3DBuilder.hpp:153
auto RotationAxis3(T angle0, T angle1, T angle2)
Rotates around three axes in succession.
Definition: Rotation3DBuilder.hpp:225
constexpr int RowCount() const
Returns the number of rows of the matrix.
Definition: MatrixImpl.hpp:31
bool IsNormalized(const Quaternion< T, Packed > &q)
Check if the quaternion is a unit quaternion, with some tolerance for floats.
Definition: QuaternionFunction.hpp:78