 |
AGX Dynamics
2.38.0.2
|
Go to the documentation of this file.
19 #ifndef AGX_QUATTEMPLATE_H
20 #define AGX_QUATTEMPLATE_H
30 # pragma warning(push)
31 # pragma warning(disable: 6385) // Disable warning C6385: Reading invalid data
41 class AffineMatrix4x4T;
96 template <
typename T2>
129 void set( T
x, T
y, T
z, T
w );
399 const T*
ptr()
const;
407 template <
typename T>
416 template <
typename T>
425 template <
typename T>
434 template <
typename T>
437 setRotate( angle, axis );
440 template <
typename T>
445 setRotate( angle1, axis1, angle2, axis2, angle3, axis3 );
448 template <
typename T>
451 setRotate( from, to );
455 template <
typename T>
456 template <
typename T2>
459 m_data[ 0 ] = (T)copy[ 0 ];
460 m_data[ 1 ] = (T)copy[ 1 ];
461 m_data[ 2 ] = (T)copy[ 2 ];
462 m_data[ 3 ] = (T)copy[ 3 ];
465 template <
typename T>
472 template <
typename T>
482 template <
typename T>
485 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];
488 template <
typename T>
491 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];
494 template <
typename T>
497 return Vec4T<T>( m_data[0], m_data[1], m_data[2], m_data[3] );
500 template <
typename T>
503 return Vec3T<T>( m_data[0], m_data[1], m_data[2] );
506 template <
typename T>
515 template <
typename T>
524 template <
typename T>
531 template <
typename T>
538 template <
typename T>
544 template <
typename T>
550 template <
typename T>
556 template <
typename T>
562 template <
typename T>
568 template <
typename T>
574 template <
typename T>
580 template <
typename T>
586 template <
typename T>
589 return m_data[0] == 0.0 && m_data[1] == 0.0 && m_data[2] == 0.0 && m_data[3] == 1.0;
593 template <
typename T>
596 return QuatT( m_data[0] * rhs, m_data[1] * rhs, m_data[2] * rhs, m_data[3] * rhs );
599 template <
typename T>
609 template <
typename T>
618 template <
typename T>
621 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];
622 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];
623 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];
624 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];
633 template <
typename T>
636 return (*
this) * rhs ;
639 template <
typename T>
642 return rhs * (*this) ;
646 template <
typename T>
650 return QuatT( m_data[0] * div, m_data[1] * div, m_data[2] * div, m_data[3] * div );
653 template <
typename T>
664 template <
typename T>
667 return ( ( *
this ) * denom.
inverse() );
670 template <
typename T>
673 ( *this ) = ( *this ) * denom.
inverse();
677 template <
typename T>
684 template <
typename T>
687 m_data[0] += rhs.
m_data[0];
688 m_data[1] += rhs.
m_data[1];
689 m_data[2] += rhs.
m_data[2];
690 m_data[3] += rhs.
m_data[3];
694 template <
typename T>
701 template <
typename T>
704 m_data[0] -= rhs.
m_data[0];
705 m_data[1] -= rhs.
m_data[1];
706 m_data[2] -= rhs.
m_data[2];
707 m_data[3] -= rhs.
m_data[3];
711 template <
typename T>
714 return QuatT<T> ( -m_data[0], -m_data[1], -m_data[2], -m_data[3] );
717 template <
typename T>
720 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] );
723 template <
typename T>
726 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];
729 template <
typename T>
732 return QuatT( -m_data[0], -m_data[1], -m_data[2], m_data[3] );
735 template <
typename T>
738 return conj() / length2();
742 template <
typename T>
745 return rotate( angle,
Vec3T<T>( x, y, z ) );
748 template <
typename T>
756 template <
typename T>
762 q.
setRotate( angle1, axis1, angle2, axis2, angle3, axis3 );
766 template <
typename T>
775 template <
typename T>
780 Vec3T<T> qvec( m_data[0], m_data[1], m_data[2] );
783 uv *= ( 2.0f * m_data[3] );
788 template <
typename T>
791 T norm = this->length();
803 template <
typename T>
809 template <
typename T>
816 template <
typename T>
827 template <
typename T>
830 output << quat[0] <<
" "
840 # pragma warning(pop)
void set(T x, T y, T z, T w)
Set the 4 elements of the quaternion as 4 scalars.
T normalize()
Normalize the quat so that it has unit length.
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
QuatT< T > inverse() const
Multiplicative inverse method: q^(-1) = q^*/(q.q^*)
QuatT< T > operator/(T rhs) const
Divide by scalar rhs.
const QuatT< T > operator-() const
Negation operator - returns the negative of the quaternion.
bool operator==(const QuatT< T > &v) const
Test for equality.
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)
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;.
Specialized types of matrices for holding orthogonal transformation matrices.
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...
void slerp(T t, const QuatT< T > &from, const QuatT< T > &to)
Spherical Linear Interpolation.
Matrix class for rigid transformations (translation, rotation).
bool zeroRotation() const
A class holding 4 dimensional vectors and providing basic arithmetic.
QuatT< T > & operator*=(T rhs)
Unary multiply by scalar rhs.
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,...
Vec3T< T > asVec3() const
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Convention
The 24 Euler conventions.
agx::Real getAngle() const
Get the rotation angle represented by the quaternion.
const QuatT< T > operator*(T rhs) const
Multiply by scalar rhs.
QuatT< T > & operator+=(const QuatT< T > &rhs)
Unary addition.
const Real AGX_EQUIVALENT_EPSILON
agx::Vec3T< T > getUnitVector() const
Get the rotation unit vector represented by the quaternion.
QuatT< T > & operator=(const QuatT< T > &v)
Assignment operator.
QuatT()
Default constructor. Create a Quaternion with an identity rotation.
QuatT< T > & operator/=(T rhs)
Unary divide by scalar rhs.
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
void get(EulerAngles &euler) const
Convert this quaternion to an EulerAngles representation.
The object holding quaternions and providing operations on these.
QuatT< T > & operator-=(const QuatT< T > &rhs)
Unary subtraction.
const QuatT< T > rightMult(const QuatT< T > &rhs) const
Binary RIGHT multiplication: q = p * rhs ; results in q = p quatmultiply rhs ;.
A class holding 3 dimensional vectors and providing basic arithmetic.
const QuatT< T > operator+(const QuatT< T > &rhs) const
Binary addition.
void getRotate(T &angle, T &x, T &y, T &z) const
Get the angle and vector components represented by the quaternion.
Vec4T< T > asVec4() const
bool operator!=(const QuatT< T > &v) const
Vec3T< T > getAsEulerAngles(agx::EulerConvention::Convention convention=agx::EulerConvention::Convention::DEFAULT_CONVENTION) const
Convert to Euler anglers.