| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkVersorTransform.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:49 $ |
| 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 |
|
|
| 18 |
|
#ifndef __itkVersorTransform_h |
| 19 |
|
#define __itkVersorTransform_h |
| 20 |
|
|
| 21 |
|
#include <iostream> |
| 22 |
|
#include "itkRigid3DTransform.h" |
| 23 |
|
#include "vnl/vnl_quaternion.h" |
| 24 |
|
#include "itkVersor.h" |
| 25 |
|
|
| 26 |
|
namespace itk |
| 27 |
|
{ |
| 28 |
|
|
| 29 |
|
/** |
| 30 |
|
* |
| 31 |
|
* VersorTransform of a vector space (e.g. space coordinates) |
| 32 |
|
* |
| 33 |
|
* This transform applies a rotation to the space. |
| 34 |
|
* |
| 35 |
|
* \ingroup Transforms |
| 36 |
|
* |
| 37 |
|
**/ |
| 38 |
LEN |
template < class TScalarType=double > // Data type for scalars (float or double) |
| 39 |
MCM |
class ITK_EXPORT VersorTransform : |
| 40 |
IND |
**public Rigid3DTransform< TScalarType > |
| 41 |
|
{ |
| 42 |
|
public: |
| 43 |
|
|
| 44 |
IND |
****/** Standard Self Typedef */ |
| 45 |
IND |
****typedef VersorTransform Self; |
| 46 |
IND |
****typedef Rigid3DTransform< TScalarType > Superclass; |
| 47 |
IND |
****typedef SmartPointer<Self> Pointer; |
| 48 |
IND |
****typedef SmartPointer<const Self> ConstPointer; |
| 49 |
|
|
| 50 |
IND |
****/** Run-time type information (and related methods). */ |
| 51 |
IND |
****itkTypeMacro( VersorTransform, Rigid3DTransform ); |
| 52 |
|
|
| 53 |
IND |
****/** New macro for creation of through a Smart Pointer */ |
| 54 |
IND |
****itkNewMacro( Self ); |
| 55 |
|
|
| 56 |
IND |
****/** Dimension of parameters */ |
| 57 |
IND |
****itkStaticConstMacro(SpaceDimension, unsigned int, 3); |
| 58 |
IND |
****itkStaticConstMacro(InputSpaceDimension, unsigned int, 3); |
| 59 |
IND |
****itkStaticConstMacro(OutputSpaceDimension, unsigned int, 3); |
| 60 |
IND |
****itkStaticConstMacro(ParametersDimension, unsigned int, 3); |
| 61 |
|
|
| 62 |
IND |
****/** Parameters Type */ |
| 63 |
IND |
****typedef typename Superclass::ParametersType ParametersType; |
| 64 |
IND |
****typedef typename Superclass::JacobianType JacobianType; |
| 65 |
IND |
****typedef typename Superclass::ScalarType ScalarType; |
| 66 |
IND |
****typedef typename Superclass::InputPointType InputPointType; |
| 67 |
IND |
****typedef typename Superclass::OutputPointType OutputPointType; |
| 68 |
IND |
****typedef typename Superclass::InputVectorType InputVectorType; |
| 69 |
IND |
****typedef typename Superclass::OutputVectorType OutputVectorType; |
| 70 |
IND |
****typedef typename Superclass::InputVnlVectorType InputVnlVectorType; |
| 71 |
IND |
****typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; |
| 72 |
IND |
****typedef typename Superclass::InputCovariantVectorType |
| 73 |
TDA,IND |
******************************************************InputCovariantVectorType; |
| 74 |
IND |
****typedef typename Superclass::OutputCovariantVectorType |
| 75 |
TDA,IND |
******************************************************OutputCovariantVectorType; |
| 76 |
IND |
****typedef typename Superclass::MatrixType MatrixType; |
| 77 |
IND |
****typedef typename Superclass::InverseMatrixType InverseMatrixType; |
| 78 |
IND |
****typedef typename Superclass::CenterType CenterType; |
| 79 |
IND |
****typedef typename Superclass::OffsetType OffsetType; |
| 80 |
|
|
| 81 |
IND |
****/** |
| 82 |
IND |
****** VnlQuaternion Type |
| 83 |
IND |
******/ |
| 84 |
IND |
****typedef vnl_quaternion<TScalarType> VnlQuaternionType; |
| 85 |
|
|
| 86 |
IND |
****/** |
| 87 |
IND |
****** Versor Type |
| 88 |
IND |
******/ |
| 89 |
IND |
****typedef Versor<TScalarType> VersorType; |
| 90 |
IND |
****typedef typename VersorType::VectorType AxisType; |
| 91 |
IND |
****typedef typename VersorType::ValueType AngleType; |
| 92 |
|
|
| 93 |
|
|
| 94 |
EML |
|
| 95 |
IND |
****/** |
| 96 |
IND |
****** Set the transformation from a container of parameters |
| 97 |
IND |
****** This is typically used by optimizers. |
| 98 |
IND |
****** |
| 99 |
IND |
****** There are 3 parameters. They represent the components |
| 100 |
IND |
****** of the right part of the versor. This can be seen |
| 101 |
IND |
****** as the components of the vector parallel to the rotation |
| 102 |
IND |
****** axis and multiplied by sin( angle / 2 ). |
| 103 |
IND |
****** |
| 104 |
IND |
*******/ |
| 105 |
IND |
****void SetParameters( const ParametersType & parameters ); |
| 106 |
|
|
| 107 |
IND |
****/** Get the Transformation Parameters. */ |
| 108 |
IND |
****const ParametersType& GetParameters(void) const; |
| 109 |
|
|
| 110 |
IND |
****/** |
| 111 |
IND |
****** Set the rotational part of the transform |
| 112 |
IND |
*******/ |
| 113 |
IND |
****void SetRotation( const VersorType & versor ); |
| 114 |
IND |
****void SetRotation( const AxisType & axis, AngleType angle ); |
| 115 |
IND |
****itkGetConstReferenceMacro(Versor, VersorType); |
| 116 |
|
|
| 117 |
IND |
****/** Set the parameters to the IdentityTransform */ |
| 118 |
IND |
****virtual void SetIdentity(void); |
| 119 |
|
|
| 120 |
IND |
****/** |
| 121 |
IND |
****** Compute the Jacobian of the transformation |
| 122 |
IND |
****** |
| 123 |
IND |
****** This method computes the Jacobian matrix of the transformation. |
| 124 |
IND |
****** given point or vector, returning the transformed point or |
| 125 |
IND |
****** vector. The rank of the Jacobian will also indicate if the |
| 126 |
IND |
****** transform is invertible at this point. |
| 127 |
IND |
******/ |
| 128 |
IND |
****const JacobianType & GetJacobian(const InputPointType &point ) const; |
| 129 |
|
|
| 130 |
IND |
*protected: |
| 131 |
IND |
****/** |
| 132 |
IND |
****** Construct an VersorTransform object |
| 133 |
IND |
****** |
| 134 |
IND |
*******/ |
| 135 |
IND |
****VersorTransform(const MatrixType &matrix, |
| 136 |
|
const OutputVectorType &offset); |
| 137 |
IND |
****VersorTransform(unsigned int outputDims, |
| 138 |
|
unsigned int paramDims); |
| 139 |
IND |
****VersorTransform(); |
| 140 |
|
|
| 141 |
IND |
****/** |
| 142 |
IND |
****** Destroy an VersorTransform object |
| 143 |
IND |
*******/ |
| 144 |
IND |
****~VersorTransform(){}; |
| 145 |
|
|
| 146 |
IND |
****/** This method must be made protected here because it is not a safe way of |
| 147 |
IND |
****** initializing the Versor */ |
| 148 |
IND |
****virtual void SetRotationMatrix(const MatrixType & matrix) |
| 149 |
IND |
******{ this->Superclass::SetRotationMatrix( matrix ); } |
| 150 |
|
|
| 151 |
IND |
****void SetVarVersor(const VersorType & newVersor) |
| 152 |
IND |
******{ m_Versor = newVersor; } |
| 153 |
|
|
| 154 |
IND |
****/** |
| 155 |
IND |
****** Print contents of a VersorTransform |
| 156 |
IND |
*******/ |
| 157 |
IND |
****void PrintSelf(std::ostream &os, Indent indent) const; |
| 158 |
|
|
| 159 |
|
|
| 160 |
IND |
****/** |
| 161 |
IND |
****** Compute Matrix |
| 162 |
IND |
****** Compute the components of the rotation matrix in the superclass |
| 163 |
IND |
*******/ |
| 164 |
IND |
****void ComputeMatrix(void); |
| 165 |
IND |
****void ComputeMatrixParameters(void); |
| 166 |
|
|
| 167 |
|
private: |
| 168 |
IND |
****/** |
| 169 |
IND |
****** Copy a VersorTransform object |
| 170 |
IND |
*******/ |
| 171 |
IND |
****VersorTransform(const Self & other); // Not implemented |
| 172 |
|
|
| 173 |
IND |
****/** |
| 174 |
IND |
****** Assignment operator |
| 175 |
IND |
*******/ |
| 176 |
IND |
****const Self & operator=( const Self & ); // Not implemented |
| 177 |
|
|
| 178 |
IND |
****/** |
| 179 |
IND |
****** Versor containing the rotation |
| 180 |
IND |
******/ |
| 181 |
IND |
****VersorType m_Versor; |
| 182 |
|
|
| 183 |
|
}; //class VersorTransform |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
} // namespace itk |
| 187 |
|
|
| 188 |
|
|
| 189 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 190 |
|
#include "itkVersorTransform.txx" |
| 191 |
|
#endif |
| 192 |
|
|
| 193 |
|
#endif /* __itkVersorTransform_h */ |
| 194 |
|
|