| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkQuaternionRigidTransform.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:46 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkQuaternionRigidTransform_h |
| 18 |
|
#define __itkQuaternionRigidTransform_h |
| 19 |
|
|
| 20 |
|
#include <iostream> |
| 21 |
|
#include "itkRigid3DTransform.h" |
| 22 |
|
#include "vnl/vnl_quaternion.h" |
| 23 |
|
|
| 24 |
|
namespace itk |
| 25 |
|
{ |
| 26 |
|
|
| 27 |
|
/** \brief QuaternionRigidTransform of a vector space (e.g. space coordinates). |
| 28 |
|
* |
| 29 |
|
* This transform applies a rotation and translation to the space |
| 30 |
|
* |
| 31 |
|
* \ingroup Transforms |
| 32 |
|
*/ |
| 33 |
LEN |
template < class TScalarType=double > // Data type for scalars (float or double) |
| 34 |
MCM |
class ITK_EXPORT QuaternionRigidTransform : |
| 35 |
IND |
********public Rigid3DTransform< TScalarType > |
| 36 |
|
{ |
| 37 |
|
public: |
| 38 |
|
/** Standard class typedefs. */ |
| 39 |
|
typedef QuaternionRigidTransform Self; |
| 40 |
|
typedef Rigid3DTransform< TScalarType > Superclass; |
| 41 |
|
typedef SmartPointer<Self> Pointer; |
| 42 |
|
typedef SmartPointer<const Self> ConstPointer; |
| 43 |
|
|
| 44 |
|
/** New macro for creation of through a Smart Pointer */ |
| 45 |
|
itkNewMacro( Self ); |
| 46 |
|
|
| 47 |
|
/** Run-time type information (and related methods). */ |
| 48 |
|
itkTypeMacro( QuaternionRigidTransform, Rigid3DTransform ); |
| 49 |
|
|
| 50 |
|
/** Dimension of parameters */ |
| 51 |
|
itkStaticConstMacro(InputSpaceDimension, unsigned int, 3); |
| 52 |
|
itkStaticConstMacro(OutputSpaceDimension, unsigned int, 3); |
| 53 |
|
itkStaticConstMacro(SpaceDimension, unsigned int, 3); |
| 54 |
|
itkStaticConstMacro(ParametersDimension, unsigned int, 7); |
| 55 |
|
|
| 56 |
|
/** Parameters Type */ |
| 57 |
|
typedef typename Superclass::ParametersType ParametersType; |
| 58 |
|
typedef typename Superclass::JacobianType JacobianType; |
| 59 |
|
typedef typename Superclass::ScalarType ScalarType; |
| 60 |
|
typedef typename Superclass::InputPointType InputPointType; |
| 61 |
|
typedef typename Superclass::OutputPointType OutputPointType; |
| 62 |
|
typedef typename Superclass::InputVectorType InputVectorType; |
| 63 |
|
typedef typename Superclass::OutputVectorType OutputVectorType; |
| 64 |
|
typedef typename Superclass::InputVnlVectorType InputVnlVectorType; |
| 65 |
|
typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; |
| 66 |
|
typedef typename Superclass::InputCovariantVectorType |
| 67 |
IND |
******************************************************InputCovariantVectorType; |
| 68 |
|
typedef typename Superclass::OutputCovariantVectorType |
| 69 |
IND |
******************************************************OutputCovariantVectorType; |
| 70 |
|
typedef typename Superclass::MatrixType MatrixType; |
| 71 |
|
typedef typename Superclass::InverseMatrixType InverseMatrixType; |
| 72 |
|
typedef typename Superclass::CenterType CenterType; |
| 73 |
|
typedef typename Superclass::OffsetType OffsetType; |
| 74 |
|
typedef typename Superclass::TranslationType TranslationType; |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
/** VnlQuaternion type. */ |
| 78 |
|
typedef vnl_quaternion<TScalarType> VnlQuaternionType; |
| 79 |
|
|
| 80 |
|
/** Compute the Jacobian Matrix of the transformation at one point */ |
| 81 |
|
/** Set the rotation of the rigid transform. |
| 82 |
|
* This method sets the rotation of a QuaternionRigidTransform to a |
| 83 |
|
* value specified by the user. */ |
| 84 |
|
void SetRotation(const VnlQuaternionType &rotation); |
| 85 |
|
|
| 86 |
|
/** Get the rotation from an QuaternionRigidTransform. |
| 87 |
|
* This method returns the value of the rotation of the |
| 88 |
|
* QuaternionRigidTransform. **/ |
| 89 |
|
const VnlQuaternionType & GetRotation(void) const |
| 90 |
|
{ return m_Rotation; } |
| 91 |
|
|
| 92 |
|
/** Set the parameters to the IdentityTransform */ |
| 93 |
|
virtual void SetIdentity(void); |
| 94 |
|
|
| 95 |
|
/** Set the transformation from a container of parameters. |
| 96 |
|
* This is typically used by optimizers. |
| 97 |
|
* There are 7 parameters. The first four represents the |
| 98 |
|
* quaternion and the last three represents the |
| 99 |
|
* offset. */ |
| 100 |
|
void SetParameters( const ParametersType & parameters ); |
| 101 |
|
virtual const ParametersType & GetParameters() const; |
| 102 |
|
|
| 103 |
|
/** Compute the Jacobian of the transformation. |
| 104 |
|
* This method computes the Jacobian matrix of the transformation. |
| 105 |
|
* given point or vector, returning the transformed point or |
| 106 |
|
* vector. The rank of the Jacobian will also indicate if the transform |
| 107 |
|
* is invertible at this point. */ |
| 108 |
|
const JacobianType & GetJacobian(const InputPointType &point ) const; |
| 109 |
|
|
| 110 |
|
protected: |
| 111 |
|
QuaternionRigidTransform(const MatrixType &matrix, |
| 112 |
|
const OutputVectorType &offset); |
| 113 |
|
QuaternionRigidTransform(unsigned int outputDims, |
| 114 |
|
unsigned int paramDims); |
| 115 |
|
QuaternionRigidTransform(); |
| 116 |
|
~QuaternionRigidTransform(){}; |
| 117 |
|
|
| 118 |
|
void ComputeMatrix(); |
| 119 |
|
|
| 120 |
|
void ComputeMatrixParameters(); |
| 121 |
|
|
| 122 |
|
void SetVarRotation(const VnlQuaternionType & rotation) |
| 123 |
|
{ m_Rotation = rotation; }; |
| 124 |
|
|
| 125 |
|
const InverseMatrixType & GetInverseMatrix( void ) const; |
| 126 |
|
|
| 127 |
|
void PrintSelf(std::ostream &os, Indent indent) const; |
| 128 |
|
|
| 129 |
|
private: |
| 130 |
|
QuaternionRigidTransform(const Self&); //purposely not implemented |
| 131 |
|
void operator=(const Self&); //purposely not implemented |
| 132 |
|
|
| 133 |
|
/** Rotation of the transformation. */ |
| 134 |
|
VnlQuaternionType m_Rotation; |
| 135 |
|
|
| 136 |
|
}; //class QuaternionRigidTransform |
| 137 |
|
|
| 138 |
|
|
| 139 |
|
} // namespace itk |
| 140 |
|
|
| 141 |
|
|
| 142 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 143 |
|
#include "itkQuaternionRigidTransform.txx" |
| 144 |
|
#endif |
| 145 |
|
|
| 146 |
|
#endif /* __itkQuaternionRigidTransform_h */ |
| 147 |
|
|