19 #ifndef AGX_QUATTEMPLATE_H
20 #define AGX_QUATTEMPLATE_H
30 # pragma warning(push)
31 # pragma warning(disable: 6385)
41 class AffineMatrix4x4T;
96 template <
typename T2>
396 void set( T val,
size_t i );
414 template <
typename T>
423 template <
typename T>
432 template <
typename T>
441 template <
typename T>
444 setRotate( angle, axis );
447 template <
typename T>
452 setRotate( angle1, axis1, angle2, axis2, angle3, axis3 );
455 template <
typename T>
458 setRotate( from, to );
462 template <
typename T>
463 template <
typename T2>
466 m_data[ 0 ] = (T)copy[ 0 ];
467 m_data[ 1 ] = (T)copy[ 1 ];
468 m_data[ 2 ] = (T)copy[ 2 ];
469 m_data[ 3 ] = (T)copy[ 3 ];
472 template <
typename T>
479 template <
typename T>
489 template <
typename T>
492 return m_data[0] == v.
m_data[0] && m_data[1] == v.
m_data[1] && m_data[2] == v.
m_data[2] && m_data[3] == v.
m_data[3];
495 template <
typename T>
498 return m_data[0] != v.
m_data[0] || m_data[1] != v.
m_data[1] || m_data[2] != v.
m_data[2] || m_data[3] != v.
m_data[3];
501 template <
typename T>
504 return Vec4T<T>( m_data[0], m_data[1], m_data[2], m_data[3] );
507 template <
typename T>
510 return Vec3T<T>( m_data[0], m_data[1], m_data[2] );
513 template <
typename T>
522 template <
typename T>
531 template <
typename T>
538 template <
typename T>
545 template <
typename T>
551 template <
typename T>
557 template <
typename T>
563 template <
typename T>
569 template <
typename T>
575 template <
typename T>
581 template <
typename T>
587 template <
typename T>
593 template <
typename T>
596 return m_data[0] == 0.0 && m_data[1] == 0.0 && m_data[2] == 0.0 && m_data[3] == 1.0;
600 template <
typename T>
603 return QuatT( m_data[0] * rhs, m_data[1] * rhs, m_data[2] * rhs, m_data[3] * rhs );
606 template <
typename T>
616 template <
typename T>
625 template <
typename T>
628 T x = rhs.
m_data[3] * m_data[0] + rhs.
m_data[0] * m_data[3] + rhs.
m_data[1] * m_data[2] - rhs.
m_data[2] * m_data[1];
629 T y = rhs.
m_data[3] * m_data[1] - rhs.
m_data[0] * m_data[2] + rhs.
m_data[1] * m_data[3] + rhs.
m_data[2] * m_data[0];
630 T z = rhs.
m_data[3] * m_data[2] + rhs.
m_data[0] * m_data[1] - rhs.
m_data[1] * m_data[0] + rhs.
m_data[2] * m_data[3];
631 m_data[3] = rhs.
m_data[3] * m_data[3] - rhs.
m_data[0] * m_data[0] - rhs.
m_data[1] * m_data[1] - rhs.
m_data[2] * m_data[2];
640 template <
typename T>
643 return (*
this) * rhs ;
646 template <
typename T>
649 return rhs * (*this) ;
653 template <
typename T>
657 return QuatT( m_data[0] * div, m_data[1] * div, m_data[2] * div, m_data[3] * div );
660 template <
typename T>
671 template <
typename T>
674 return ( ( *
this ) * denom.
inverse() );
677 template <
typename T>
680 ( *this ) = ( *this ) * denom.
inverse();
684 template <
typename T>
691 template <
typename T>
694 m_data[0] += rhs.
m_data[0];
695 m_data[1] += rhs.
m_data[1];
696 m_data[2] += rhs.
m_data[2];
697 m_data[3] += rhs.
m_data[3];
701 template <
typename T>
708 template <
typename T>
711 m_data[0] -= rhs.
m_data[0];
712 m_data[1] -= rhs.
m_data[1];
713 m_data[2] -= rhs.
m_data[2];
714 m_data[3] -= rhs.
m_data[3];
718 template <
typename T>
721 return QuatT<T> ( -m_data[0], -m_data[1], -m_data[2], -m_data[3] );
724 template <
typename T>
727 return std::sqrt( m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2] + m_data[3] * m_data[3] );
730 template <
typename T>
733 return m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2] + m_data[3] * m_data[3];
736 template <
typename T>
739 return QuatT( -m_data[0], -m_data[1], -m_data[2], m_data[3] );
742 template <
typename T>
745 return conj() / length2();
749 template <
typename T>
752 return rotate( angle,
Vec3T<T>( x, y, z ) );
755 template <
typename T>
763 template <
typename T>
769 q.
setRotate( angle1, axis1, angle2, axis2, angle3, axis3 );
773 template <
typename T>
782 template <
typename T>
787 Vec3T<T> qvec( m_data[0], m_data[1], m_data[2] );
790 uv *= ( 2.0f * m_data[3] );
795 template <
typename T>
798 T norm = this->length();
810 template <
typename T>
816 template <
typename T>
822 template <
typename T>
828 template <
typename T>
835 template <
typename T>
846 template <
typename T>
849 output << quat[0] <<
" "
859 # pragma warning(pop)
Matrix class for rigid transformations (translation, rotation).
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Convention
The 24 Euler conventions.
Specialized types of matrices for holding orthogonal transformation matrices.
The object holding quaternions and providing operations on these.
T normalize()
Normalize the quat so that it has unit length.
agx::Real getAngle() const
Get the rotation angle represented by the quaternion.
void getRotate(T &angle, T &x, T &y, T &z) const
Get the angle and vector components represented by the quaternion.
void set(T val, size_t i)
Set the value of element i. Mainly for accessing QuatT<T> in Lua.
QuatT< T > inverse() const
Multiplicative inverse method: q^(-1) = q^*/(q.q^*)
QuatT()
Default constructor. Create a Quaternion with an identity rotation.
const QuatT< T > operator/(const QuatT< T > &denom) const
Binary divide.
QuatT< T > & operator/=(T rhs)
Unary divide by scalar rhs.
QuatT< T > & operator*=(T rhs)
Unary multiply by scalar rhs.
bool operator!=(const QuatT< T > &v) const
QuatT< T > & operator=(const QuatT< T > &v)
Assignment operator.
void slerp(T t, const QuatT< T > &from, const QuatT< T > &to)
Spherical Linear Interpolation.
static QuatT< T > rotate(const Vec3T< T > &from, const Vec3T< T > &to)
Static method which constructs and returns a Quaternion from rotating vector from to vector to.
bool zeroRotation() const
void set(const Vec4T< T > &v)
Set the four elements of the quaternion as an Vec4.
const QuatT< T > rightMult(const QuatT< T > &rhs) const
Binary RIGHT multiplication: q = p * rhs ; results in q = p quatmultiply rhs ;.
void setRotate(const Vec3T< T > &from, const Vec3T< T > &to)
Make a rotation QuatT<T> which will rotate from to to Generally take a dot product to get the angle b...
static QuatT< T > rotate(T angle, T x, T y, T z)
Static method which constructs and returns a Quaternion from a rotation given as angle radians around...
QuatT< T > & set(const OrthoMatrix3x3 &matrix)
Set this quaternion with the rotation described by a OrthoMatrix3x3.
agx::Vec3T< T > getUnitVector() const
Get the rotation unit vector represented by the quaternion.
QuatT< T > & operator*=(const QuatT< T > &rhs)
Unary LEFT multiply: result is this = rhs quatmultiply this, which makes sense since the notation sug...
void get(EulerAngles &euler) const
Convert this quaternion to an EulerAngles representation.
QuatT(T angle, const Vec3T< T > &axis)
Create a Quaternion calculated from a rotation of angle radians around the rotation axis axis.
QuatT(T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3)
Create a Quaternion based on the concatenation between the three specified angle and axis.
static QuatT< T > rotate(T angle, const Vec3T< T > &vec)
Static method which constructs and returns a Quaternion from a rotation given as angle radians around...
const QuatT< T > leftMult(const QuatT< T > &rhs) const
Binary left multiplication: q = p * rhs; results in the OTHER WAY AROUND: q = rhs quatmultiply p;.
QuatT(const AffineMatrix4x4T< T > &matrix)
Create a Quaternion based on the rotation part in the specified Affine 4x4 transformation matrix.
void setRotate(T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3)
Set the rotation of this Quaternion as a concatenation of the three angle/axis rotations:
Vec3T< T > getAsEulerAngles(agx::EulerConvention::Convention convention=agx::EulerConvention::Convention::DEFAULT_CONVENTION) const
Convert to Euler anglers.
QuatT< T > & set(const EulerAngles &euler)
Set this quaternion with the rotation described by the EulerAngles representation.
void get(T &angle, agx::Vec3T< T > &axis) const
Convert a Quaternion to an axis and angle representation.
QuatT(T x, T y, T z, T w)
Create a Quaternion with the specified scalar values.
void setRotate(T angle, T x, T y, T z)
Set the rotation of the Quaternion as a rotation angle radians around the vector (x,...
void get(OrthoMatrix3x3 &matrix) const
Set an OrthoMatrix3x3 to represent the same rotation as the quaternion.
Vec3T< T > asVec3() const
const QuatT< T > operator*(T rhs) const
Multiply by scalar rhs.
QuatT(const Vec4T< T > &v)
Create a Quaternion based on the 4D vector (x,y,z,w)
QuatT(const EulerAngles &euler)
Create a Quaternion based on the rotation from euler specified as a EulerAngle.
Vec4T< T > asVec4() const
const QuatT< T > operator*(const QuatT< T > &rhs) const
Binary LEFT multiply: result is q = rhs quatmultiply this, even though the notation is q = this * rhs...
QuatT(const QuatT< T > ©)=default
Copy constructor.
void get(AffineMatrix4x4T< T > &matrix) const
Set the Rotational part of matrix from this quaternion.
void setRotate(T angle, const Vec3T< T > &vec)
Set the rotation of this Quaternion as a rotation angle radians around the vector vec.
bool operator==(const QuatT< T > &v) const
Test for equality.
const QuatT< T > operator-() const
Negation operator - returns the negative of the quaternion.
QuatT< T > & set(const AffineMatrix4x4T< T > &matrix)
Set this quaternion with the rotational part of matrix.
QuatT(const QuatT< T2 > ©)
Copy constructor for other types.
void getRotate(T &angle, Vec3T< T > &vec) const
Get the angle and vector represented by the quaternion.
const QuatT< T > operator+(const QuatT< T > &rhs) const
Binary addition.
void set(T x, T y, T z, T w)
Set the 4 elements of the quaternion as 4 scalars.
QuatT(const Vec3T< T > &from, const Vec3T< T > &to)
Create a Quaternion which maps the rotation from vector from to the vector to.
QuatT< T > & operator/=(const QuatT< T > &denom)
Unary divide.
QuatT< T > & operator+=(const QuatT< T > &rhs)
Unary addition.
QuatT< T > operator/(T rhs) const
Divide by scalar rhs.
QuatT< T > & operator-=(const QuatT< T > &rhs)
Unary subtraction.
static QuatT< T > rotate(T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3)
Static method which constructs and returns a Quaternion from a rotation given as a concatenation of t...
A class holding 3 dimensional vectors and providing basic arithmetic.
A class holding 4 dimensional vectors and providing basic arithmetic.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
const Real AGX_EQUIVALENT_EPSILON
std::ostream & operator<<(std::ostream &stream, const AtomicValueT< T > &value)
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)