8#ifndef META_OCEAN_MATH_ROTATION_H
9#define META_OCEAN_MATH_ROTATION_H
356 ocean_assert(quaternion.
isValid());
370 const T factor = T(1.0) / invFactor;
372 VectorT3<T> axis(quaternion.
x() * factor, quaternion.
y() * factor, quaternion.
z() * factor);
396 const T cosValue = (matrix.
trace() - T(1.0)) * T(0.5);
400 ocean_assert(
false &&
"Invalid rotation matrix, containing scale.");
416 unsigned int select = 0;
417 T maximum = matrix(0, 0);
419 if (maximum < matrix(1, 1))
422 maximum = matrix(1, 1);
424 if (maximum < matrix(2, 2))
434 T factor = T(0.5) /
axis(0);
436 axis(1) = matrix(0, 1) * factor;
437 axis(2) = matrix(0, 2) * factor;
444 T factor = T(0.5) /
axis(1);
446 axis(0) = matrix(0, 1) * factor;
447 axis(2) = matrix(1, 2) * factor;
454 T factor = T(0.5) /
axis(2);
456 axis(0) = matrix(0, 2) * factor;
457 axis(1) = matrix(1, 2) * factor;
470 axis =
VectorT3<T>(matrix(2, 1) - matrix(1, 2), matrix(0, 2) - matrix(2, 0), matrix(1, 0) - matrix(0, 1));
487 ocean_assert(transformation.
isValid());
498 ocean_assert(valueArray !=
nullptr);
512 ocean_assert(
axis.isUnit());
556 ocean_assert(eps >= T(0.0));
657 return !(*
this == right);
663 ocean_assert(index < 4u);
671 ocean_assert(index < 4u);
679 ocean_assert(index < 4u);
687 ocean_assert(index < 4u);
716 else if (left == -right)
727 ocean_assert(result.
isValid());
This class implements an euler rotation with angles: yaw, pitch and roll.
Definition Euler.h:82
bool isValid() const
Returns whether the euler rotation holds valid parameters.
Definition Euler.h:360
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition HomogenousMatrix4.h:110
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition HomogenousMatrix4.h:1800
SquareMatrixT3< T > orthonormalRotationMatrix() const
Returns the 3x3 orthonormal rotation matrix of the 4x4 transformation (by forcing a orthogonal and no...
Definition HomogenousMatrix4.h:1532
static T angleAdjustPositive(const T angle)
Adjusts an arbitrary angle into the range of [0.0, 2PI).
Definition Numeric.h:1770
static constexpr T pi2()
Returns 2*PI which is equivalent to 360 degree.
Definition Numeric.h:932
static constexpr T weakEps()
Returns a weak epsilon.
static constexpr bool isInsideRange(const T lower, const T value, const T upper, const T epsilon=NumericT< T >::eps())
Returns whether a value lies between a given range up to a provided epsilon border.
Definition Numeric.h:2881
static constexpr T pi()
Returns PI which is equivalent to 180 degree.
Definition Numeric.h:926
static T sqrt(const T value)
Returns the square root of a given value.
Definition Numeric.h:1537
static constexpr T eps()
Returns a small epsilon.
static bool isEqual(const T first, const T second)
Returns whether two values are equal up to a small epsilon.
Definition Numeric.h:2395
static bool angleIsEqual(const T angleA, const T angleB)
Returns whether two angles represent the same angle up to a small epsilon.
Definition Numeric.h:1825
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition Numeric.h:2096
static T acos(const T value)
Returns the arccosine of a given value.
Definition Numeric.h:2916
This class implements a unit quaternion rotation.
Definition Quaternion.h:100
const T & x() const
Returns the x value of the quaternion.
Definition Quaternion.h:900
bool isValid() const
Returns whether this quaternion is a valid unit quaternion.
Definition Quaternion.h:882
const T & w() const
Returns the w value of the quaternion.
Definition Quaternion.h:888
QuaternionT< T > normalized() const
Returns the normalized quaternion.
Definition Quaternion.h:682
const T & y() const
Returns the y value of the quaternion.
Definition Quaternion.h:912
const T & z() const
Returns the z value of the quaternion.
Definition Quaternion.h:924
This class implements a axis-angle rotation using floating point values.
Definition Rotation.h:73
RotationT()=default
Creates a rotation object with default values so that the rotation represents the identity rotation.
RotationT(const SquareMatrixT3< T > &matrix)
Creates a rotation object by a given 3x3 rotation matrix.
Definition Rotation.h:394
static RotationT< T > left_R_right(const VectorT3< T > &left, const VectorT3< T > &right)
Returns a rotation object based on two given unit vectors.
Definition Rotation.h:705
bool isEqual(const RotationT< T > &rotation, const T eps=NumericT< T >::eps()) const
Returns whether two rotations are equal up to a specified epsilon.
Definition Rotation.h:553
bool operator!=(const RotationT< T > &right) const
Returns whether two rotations are not identical up to a small epsilon.
Definition Rotation.h:655
T & operator[](unsigned int index)
Element access operator.
Definition Rotation.h:685
RotationT(const HomogenousMatrixT4< T > &transformation)
Creates a rotation object by a given 4x4 transformation matrix.
Definition Rotation.h:485
RotationT(const VectorT3< T > &reference, const VectorT3< T > &offset)
Creates a rotation object based on two given unit vectors.
Definition Rotation.h:347
T * data()
Returns a pointer to the internal values.
Definition Rotation.h:637
T operator()(unsigned int index) const
Element access operator.
Definition Rotation.h:661
RotationT(const QuaternionT< T > &quaternion)
Creates a rotation object by a given quaternion rotation.
Definition Rotation.h:354
bool operator==(const RotationT< T > &right) const
Returns whether two rotations are identical up to a small epsilon.
Definition Rotation.h:563
RotationT(const VectorT3< T > &axis, const T angle)
Creates a rotation object by an axis and the angle.
Definition Rotation.h:340
RotationT inverted() const
Returns the inverted rotation, this rotation must be valid.
Definition Rotation.h:530
VectorT3< Scalar > axis() const
RotationT(const T x, const T y, const T z, const T angle)
Creates a rotation object by four given values.
Definition Rotation.h:328
const T * operator()() const
Access operator.
Definition Rotation.h:693
RotationT operator-() const
Returns the inverse rotation, this rotation must be valid.
Definition Rotation.h:571
void invert()
Inverts this rotation, this rotation must be valid.
Definition Rotation.h:537
RotationT(const T *valueArray)
Creates a rotation object by an array with four elements.
Definition Rotation.h:496
Scalar Type
Definition Rotation.h:79
T operator[](unsigned int index) const
Element access operator.
Definition Rotation.h:677
void setAxis(const VectorT3< T > &axis)
Sets the axis of the rotation.
Definition Rotation.h:510
Scalar values_[4]
Definition Rotation.h:324
RotationT & operator*=(const QuaternionT< T > &quaternion)
Multiplies and assign two rotations, this rotation must be valid.
Definition Rotation.h:589
T & operator()(unsigned int index)
Element access operator.
Definition Rotation.h:669
VectorT3< T > operator*(const VectorT3< T > &vector) const
Rotates a 3D vector with this rotation, this rotation must be valid.
Definition Rotation.h:623
RotationT operator*(const RotationT< T > &right) const
Multiplies two rotations, this rotation must be valid.
Definition Rotation.h:601
RotationT operator*(const QuaternionT< T > &quaternion) const
Multiplies two rotations, this rotation must be valid.
Definition Rotation.h:579
void setAngle(const T angle)
Sets the angle of the rotation.
Definition Rotation.h:522
const T * data() const
Returns a pointer to the internal values.
Definition Rotation.h:631
bool isValid() const
Returns whether this rotation has valid parameters.
Definition Rotation.h:547
RotationT & operator*=(const RotationT< T > &right)
Multiplies and assign two rotations, this rotation must be valid.
Definition Rotation.h:611
RotationT(const EulerT< T > &euler)
Creates an angle-axis rotation by a given euler rotation.
Definition Rotation.h:385
T * operator()()
Access operator.
Definition Rotation.h:699
This class implements a 3x3 square matrix.
Definition SquareMatrix3.h:89
T determinant() const
Returns the determinant of the matrix.
Definition SquareMatrix3.h:1284
T trace() const
Returns the trace of the matrix which is the sum of the diagonal elements.
Definition SquareMatrix3.h:1292
This class implements a vector with three elements.
Definition Vector3.h:97
bool isUnit(const T eps=NumericT< T >::eps()) const
Returns whether this vector is a unit vector (whether the vector has the length 1).
Definition Vector3.h:865
VectorT3< T > perpendicular() const
Returns a vector that is perpendicular to this vector.
Definition Vector3.h:760
VectorT3< T > cross(const VectorT3< T > &vector) const
Returns the cross product of two vectors.
Definition Vector3.h:601
T angle(const VectorT3< T > &right) const
Returns the angle between this vector and a second vectors.
Definition Vector3.h:692
std::vector< Rotation > Rotations
Definition of a vector holding rotation objects.
Definition Rotation.h:61
std::vector< RotationT< T > > RotationsT
Definition of a typename alias for vectors with RotationT objects.
Definition Rotation.h:54
RotationT< float > RotationF
Instantiation of the RotationT template class using a single precision float data type.
Definition Rotation.h:46
RotationT< Scalar > Rotation
Definition of the Rotation object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag either with ...
Definition Rotation.h:32
RotationT< double > RotationD
Instantiation of the RotationT template class using a double precision float data type.
Definition Rotation.h:39
The namespace covering the entire Ocean framework.
Definition Accessor.h:15