ITK  5.4.0
Insight Toolkit
Public Types | Public Member Functions | Private Attributes | List of all members

#include <itkVersor.h>

Detailed Description

template<typename T>
class itk::Versor< T >

A templated class holding a unit quaternion.

Versor is a templated class that holds a unit quaternion. The difference between versors and quaternions is that quaternions can represent rotations and scale changes while versors are limited to rotations.

This class only implements the operations that maintain versors as a group, that is, any operations between versors result in another versor. For this reason, addition is not defined in this class, even though it is a valid operation between quaternions.

See also
Vector
Point
CovariantVector
Matrix
Examples
Examples/RegistrationITKv4/ChangeInformationImageFilter.cxx, and SphinxExamples/src/Filtering/ImageGrid/ChangeImageOriginSpacingOrDirection/Code.cxx.

Definition at line 50 of file itkVersor.h.

+ Collaboration diagram for itk::Versor< T >:

Public Types

using CovariantVectorType = CovariantVector< T, 3 >
 
using MatrixType = Matrix< T, 3, 3 >
 
using PointType = Point< T, 3 >
 
using RealType = typename NumericTraits< ValueType >::RealType
 
using Self = Versor
 
using ValueType = T
 
using VectorType = Vector< T, 3 >
 
using VnlQuaternionType = vnl_quaternion< T >
 
using VnlVectorType = vnl_vector_fixed< T, 3 >
 

Public Member Functions

Self Exponential (ValueType exponent) const
 
ValueType GetAngle () const
 
VectorType GetAxis () const
 
Self GetConjugate () const
 
MatrixType GetMatrix () const
 
Self GetReciprocal () const
 
VectorType GetRight () const
 
ValueType GetScalar () const
 
ValueType GetTensor () const
 
vnl_quaternion< T > GetVnlQuaternion () const
 
ValueType GetW () const
 
ValueType GetX () const
 
ValueType GetY () const
 
ValueType GetZ () const
 
 ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION (Self)
 
void Normalize ()
 
Self operator* (const Self &v) const
 
const Selfoperator*= (const Self &v)
 
Self operator/ (const Self &v) const
 
const Selfoperator/= (const Self &v)
 
Selfoperator= (const Self &v)
 
bool operator== (const Self &v) const
 
void Set (const MatrixType &mat)
 
void Set (const VectorType &axis)
 
void Set (const VectorType &axis, ValueType angle)
 
void Set (const VnlQuaternionType &)
 
void SetIdentity ()
 
void SetRotationAroundX (ValueType angle)
 
void SetRotationAroundY (ValueType angle)
 
void SetRotationAroundZ (ValueType angle)
 
Self SquareRoot () const
 
CovariantVectorType Transform (const CovariantVectorType &v) const
 
PointType Transform (const PointType &v) const
 
VectorType Transform (const VectorType &v) const
 
VnlVectorType Transform (const VnlVectorType &v) const
 
 Versor ()=default
 
 Versor (const Self &v)
 
void Set (T x, T y, T z, T w)
 

Static Private Member Functions

static ValueType Epsilon (double *)
 
static ValueType Epsilon (float *)
 
static ValueType Epsilon ()
 

Private Attributes

ValueType m_W { NumericTraits<T>::OneValue() }
 
ValueType m_X {}
 
ValueType m_Y {}
 
ValueType m_Z {}
 

Member Typedef Documentation

◆ CovariantVectorType

template<typename T>
using itk::Versor< T >::CovariantVectorType = CovariantVector<T, 3>

CovariantVector type.

Definition at line 70 of file itkVersor.h.

◆ MatrixType

template<typename T>
using itk::Versor< T >::MatrixType = Matrix<T, 3, 3>

Type of the rotation matrix equivalent to the Versor

Definition at line 79 of file itkVersor.h.

◆ PointType

template<typename T>
using itk::Versor< T >::PointType = Point<T, 3>

Point type.

Definition at line 67 of file itkVersor.h.

◆ RealType

template<typename T>
using itk::Versor< T >::RealType = typename NumericTraits<ValueType>::RealType

Type used for computations on the versor components

Definition at line 61 of file itkVersor.h.

◆ Self

template<typename T>
using itk::Versor< T >::Self = Versor

Standard class type aliases.

Definition at line 54 of file itkVersor.h.

◆ ValueType

template<typename T>
using itk::Versor< T >::ValueType = T

ValueType can be used to declare a variable that is the same type as a data element held in a Versor.

Definition at line 58 of file itkVersor.h.

◆ VectorType

template<typename T>
using itk::Versor< T >::VectorType = Vector<T, 3>

Vector type used to represent the axis.

Definition at line 64 of file itkVersor.h.

◆ VnlQuaternionType

template<typename T>
using itk::Versor< T >::VnlQuaternionType = vnl_quaternion<T>

Vnl Quaternion type.

Definition at line 76 of file itkVersor.h.

◆ VnlVectorType

template<typename T>
using itk::Versor< T >::VnlVectorType = vnl_vector_fixed<T, 3>

Vnl Vector type.

Definition at line 73 of file itkVersor.h.

Constructor & Destructor Documentation

◆ Versor() [1/2]

template<typename T>
itk::Versor< T >::Versor ( )
default

Default constructor creates a null versor (representing 0 degrees rotation).

◆ Versor() [2/2]

template<typename T>
itk::Versor< T >::Versor ( const Self v)

Copy constructor.

Member Function Documentation

◆ Epsilon() [1/3]

template<typename T>
static ValueType itk::Versor< T >::Epsilon ( )
inlinestaticprivate

use different epsilon for float and double

Definition at line 324 of file itkVersor.h.

◆ Epsilon() [2/3]

template<typename T>
static ValueType itk::Versor< T >::Epsilon ( double *  )
inlinestaticprivate

use different epsilon for float and double

Definition at line 314 of file itkVersor.h.

◆ Epsilon() [3/3]

template<typename T>
static ValueType itk::Versor< T >::Epsilon ( float *  )
inlinestaticprivate

use different epsilon for float and double

Definition at line 319 of file itkVersor.h.

◆ Exponential()

template<typename T>
Self itk::Versor< T >::Exponential ( ValueType  exponent) const

Compute the Exponential of the unit quaternion. Exponentiation by a factor is equivalent to multiplication of the rotation angle of the quaternion.

◆ GetAngle()

template<typename T>
ValueType itk::Versor< T >::GetAngle ( ) const

Returns the rotation angle in radians.

◆ GetAxis()

template<typename T>
VectorType itk::Versor< T >::GetAxis ( ) const

Returns the axis of the rotation. It is a unit vector parallel to the axis.

◆ GetConjugate()

template<typename T>
Self itk::Versor< T >::GetConjugate ( ) const

Get Conjugate versor. Returns the versor that produce a rotation by the same angle but in opposite direction.

◆ GetMatrix()

template<typename T>
MatrixType itk::Versor< T >::GetMatrix ( ) const

Get the matrix representation.

◆ GetReciprocal()

template<typename T>
Self itk::Versor< T >::GetReciprocal ( ) const

Get Reciprocal versor. Returns the versor that composed with this one will result in a scalar operator equals to 1. It is also equivalent to 1/this.

◆ GetRight()

template<typename T>
VectorType itk::Versor< T >::GetRight ( ) const

Returns the Right part It is a vector part of the Versor. It is called Right because it is equivalent to a right angle rotation.

◆ GetScalar()

template<typename T>
ValueType itk::Versor< T >::GetScalar ( ) const

Returns the Scalar part.

◆ GetTensor()

template<typename T>
ValueType itk::Versor< T >::GetTensor ( ) const

Get Tensor part of the Versor. Given that Versors are normalized quaternions this value is expected to be 1.0 always

◆ GetVnlQuaternion()

template<typename T>
vnl_quaternion<T> itk::Versor< T >::GetVnlQuaternion ( ) const

Get a vnl_quaternion with a copy of the internal memory block.

◆ GetW()

template<typename T>
ValueType itk::Versor< T >::GetW ( ) const
inline

Returns the W component.

Definition at line 202 of file itkVersor.h.

Referenced by itk::operator<<().

◆ GetX()

template<typename T>
ValueType itk::Versor< T >::GetX ( ) const
inline

Returns the X component.

Definition at line 181 of file itkVersor.h.

Referenced by itk::operator<<().

◆ GetY()

template<typename T>
ValueType itk::Versor< T >::GetY ( ) const
inline

Returns the Y component.

Definition at line 188 of file itkVersor.h.

Referenced by itk::operator<<().

◆ GetZ()

template<typename T>
ValueType itk::Versor< T >::GetZ ( ) const
inline

Returns the Z component.

Definition at line 195 of file itkVersor.h.

Referenced by itk::operator<<().

◆ ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION()

template<typename T>
itk::Versor< T >::ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION ( Self  )

◆ Normalize()

template<typename T>
void itk::Versor< T >::Normalize ( )

Normalize the Versor. Given that Versors are normalized quaternions this method is provided only for convenience when it is suspected that a versor could be out of the unit sphere.

◆ operator*()

template<typename T>
Self itk::Versor< T >::operator* ( const Self v) const

Versor operator*. Performs the composition of two versors. this operation is NOT commutative.

◆ operator*=()

template<typename T>
const Self& itk::Versor< T >::operator*= ( const Self v)

Composition operator *=. Compose the current versor with the operand and store the result in the current versor.

◆ operator/()

template<typename T>
Self itk::Versor< T >::operator/ ( const Self v) const

Versor operator/. Performs the division of two versors.

◆ operator/=()

template<typename T>
const Self& itk::Versor< T >::operator/= ( const Self v)

Division operator /=. Divide the current versor with the operand and store the result in the current versor. This is equivalent to compose the Versor with the reciprocal of the operand

See also
GetReciprocal

◆ operator=()

template<typename T>
Self& itk::Versor< T >::operator= ( const Self v)

Assignment operator =. Copy the versor argument.

◆ operator==()

template<typename T>
bool itk::Versor< T >::operator== ( const Self v) const

Versor operator== Performs the comparison between two versors. this operation uses an arbitrary threshold for the comparison.

◆ Set() [1/5]

template<typename T>
void itk::Versor< T >::Set ( const MatrixType mat)

Set the versor using an orthogonal matrix. Based on code from: https://www.euclideanspace.com/maths/geometry/rotations/ conversions/matrixToQuaternion/index.htm

◆ Set() [2/5]

template<typename T>
void itk::Versor< T >::Set ( const VectorType axis)

Set the versor using the right part. the magnitude of the vector given is assumed to be equal to std::sin(angle/2). This method will compute internally the scalar part that preserve the Versor as a unit quaternion.

◆ Set() [3/5]

template<typename T>
void itk::Versor< T >::Set ( const VectorType axis,
ValueType  angle 
)

Set the versor using a vector and angle.

The unit vector parallel to the given vector will be used. The angle is expected in radians.

◆ Set() [4/5]

template<typename T>
void itk::Versor< T >::Set ( const VnlQuaternionType )

Set the Versor from a Quaternion

Warning
After assignment, the corresponding quaternion will be normalized in order to get a consistent Versor.

◆ Set() [5/5]

template<typename T>
void itk::Versor< T >::Set ( x,
y,
z,
w 
)

Set the Versor from Quaternion components.

Warning
After assignment, the corresponding quaternion will be normalized in order to get a consistent Versor. Also, if the "w" component is negative, the four components will be negated in order to produce a quaternion where "w" is positive, since this is implicitly assumed in other sections of the code, in particular when "w" is computed from (x,y,z) via normalization. The reason why it is valid to negate all the components is that the rotation by angle \(\theta\), is represented by \(\sin(\frac{\theta}{2})\) in the (x,y,z) components and by \(\cos(\frac{\theta}{2})\) in the "w" component. The rotation by any \(\theta\) should be equivalent to a rotation by \(\theta + n \times \pi\), therefore we should be able to replace \(\sin(\frac{\theta}{2})\) with \(\sin(\frac{\theta}{2} + n \times \pi )\) and \(\cos(\frac{\theta}{2})\) with \(\cos(\frac{\theta}{2} + n \times \pi )\). Considering that \(\cos( n \times \pi ) = (-1)^{n}\) we can conclude that if we simultaneously change the signs of all the Versor components, the rotation that it represents remains unchanged.

◆ SetIdentity()

template<typename T>
void itk::Versor< T >::SetIdentity ( )

Reset the values so the versor is equivalent to an identity transformation. This is equivalent to set a zero angle

◆ SetRotationAroundX()

template<typename T>
void itk::Versor< T >::SetRotationAroundX ( ValueType  angle)

Sets a rotation around the X axis using the parameter as angle in radians. This is a method provided for convenience to initialize a rotation. The effect of this methods is not cumulative with any value previously stored in the Versor.

See also
Set
SetRotationAroundY
SetRotationAroundZ

◆ SetRotationAroundY()

template<typename T>
void itk::Versor< T >::SetRotationAroundY ( ValueType  angle)

Sets a rotation around the Y axis using the parameter as angle in radians. This is a method provided for convenience to initialize a rotation. The effect of this methods is not cumulative with any value previously stored in the Versor.

See also
Set
SetRotationAroundX
SetRotationAroundZ

◆ SetRotationAroundZ()

template<typename T>
void itk::Versor< T >::SetRotationAroundZ ( ValueType  angle)

Sets a rotation around the Y axis using the parameter as angle in radians. This is a method provided for convenience to initialize a rotation. The effect of this methods is not cumulative with any value previously stored in the Versor.

See also
Set
SetRotationAroundX
SetRotationAroundY

◆ SquareRoot()

template<typename T>
Self itk::Versor< T >::SquareRoot ( ) const

Get the Square root of the unit quaternion.

◆ Transform() [1/4]

template<typename T>
CovariantVectorType itk::Versor< T >::Transform ( const CovariantVectorType v) const

Transform a covariant vector.

Given that this is an orthogonal transformation CovariantVectors are transformed as vectors.

◆ Transform() [2/4]

template<typename T>
PointType itk::Versor< T >::Transform ( const PointType v) const

Transform a point.

◆ Transform() [3/4]

template<typename T>
VectorType itk::Versor< T >::Transform ( const VectorType v) const

Transform a vector.

◆ Transform() [4/4]

template<typename T>
VnlVectorType itk::Versor< T >::Transform ( const VnlVectorType v) const

Transform a vnl_vector.

Member Data Documentation

◆ m_W

template<typename T>
ValueType itk::Versor< T >::m_W { NumericTraits<T>::OneValue() }
private

Escalar component of the Versor.

Definition at line 340 of file itkVersor.h.

◆ m_X

template<typename T>
ValueType itk::Versor< T >::m_X {}
private

Component parallel to x axis.

Definition at line 331 of file itkVersor.h.

◆ m_Y

template<typename T>
ValueType itk::Versor< T >::m_Y {}
private

Component parallel to y axis.

Definition at line 334 of file itkVersor.h.

◆ m_Z

template<typename T>
ValueType itk::Versor< T >::m_Z {}
private

Component parallel to z axis.

Definition at line 337 of file itkVersor.h.


The documentation for this class was generated from the following file: