| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkRigid3DPerspectiveTransform.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:47 $ |
| 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 __itkRigid3DPerspectiveTransform_h |
| 18 |
|
#define __itkRigid3DPerspectiveTransform_h |
| 19 |
|
|
| 20 |
|
#include "itkExceptionObject.h" |
| 21 |
|
#include "vnl/vnl_quaternion.h" |
| 22 |
|
#include <iostream> |
| 23 |
|
#include "itkMatrix.h" |
| 24 |
|
#include "itkTransform.h" |
| 25 |
|
#include "itkVersor.h" |
| 26 |
|
|
| 27 |
|
namespace itk |
| 28 |
|
{ |
| 29 |
|
|
| 30 |
|
/** \brief Rigid3DTramsform of a vector space (e.g. space coordinates) |
| 31 |
|
* |
| 32 |
|
* This transform applies a rotation and translation to the 3D space |
| 33 |
|
* followed by a projection to 2D space along the Z axis. |
| 34 |
|
* |
| 35 |
|
* \ingroup Transforms |
| 36 |
|
*/ |
| 37 |
|
|
| 38 |
|
template < |
| 39 |
|
class TScalarType=double> // Data type for scalars (float or double) |
| 40 |
|
class ITK_EXPORT Rigid3DPerspectiveTransform : |
| 41 |
IND |
********public Transform< TScalarType, 3, 2 > |
| 42 |
|
{ |
| 43 |
|
public: |
| 44 |
|
/** Dimension of the domain space. */ |
| 45 |
|
itkStaticConstMacro(InputSpaceDimension, unsigned int, 3); |
| 46 |
|
itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2); |
| 47 |
|
|
| 48 |
|
/** Dimension of parameters. */ |
| 49 |
|
itkStaticConstMacro(SpaceDimension, unsigned int, 3); |
| 50 |
|
itkStaticConstMacro(ParametersDimension, unsigned int, 6); |
| 51 |
|
|
| 52 |
|
/** Standard class typedefs. */ |
| 53 |
|
typedef Rigid3DPerspectiveTransform Self; |
| 54 |
|
typedef Transform< TScalarType, |
| 55 |
|
itkGetStaticConstMacro(InputSpaceDimension), |
| 56 |
TDA |
itkGetStaticConstMacro(OutputSpaceDimension)> Superclass; |
| 57 |
|
|
| 58 |
|
typedef SmartPointer<Self> Pointer; |
| 59 |
|
typedef SmartPointer<const Self> ConstPointer; |
| 60 |
|
|
| 61 |
|
/** Run-time type information (and related methods). */ |
| 62 |
|
itkTypeMacro( Rigid3DPerspectiveTransform, Transform ); |
| 63 |
|
|
| 64 |
|
/** New macro for creation of through a Smart Pointer. */ |
| 65 |
|
itkNewMacro( Self ); |
| 66 |
|
|
| 67 |
|
/** Scalar type. */ |
| 68 |
|
typedef typename Superclass::ScalarType ScalarType; |
| 69 |
|
|
| 70 |
|
/** Parameters type. */ |
| 71 |
|
typedef typename Superclass::ParametersType ParametersType; |
| 72 |
|
|
| 73 |
|
/** Jacobian type. */ |
| 74 |
|
typedef typename Superclass::JacobianType JacobianType; |
| 75 |
|
|
| 76 |
|
/** Standard matrix type for this class. */ |
| 77 |
LEN |
typedef Matrix<TScalarType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType; |
| 78 |
|
|
| 79 |
|
/** Standard vector type for this class. */ |
| 80 |
LEN |
typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> OffsetType; |
| 81 |
|
|
| 82 |
|
/** Standard vector type for this class. */ |
| 83 |
LEN |
typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType; |
| 84 |
LEN,TDA |
typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType; |
| 85 |
|
|
| 86 |
|
/** Standard coordinate point type for this class. */ |
| 87 |
LEN |
typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType; |
| 88 |
LEN,TDA |
typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType; |
| 89 |
|
|
| 90 |
|
/** Standard vnl_quaternion type. */ |
| 91 |
|
typedef vnl_quaternion<TScalarType> VnlQuaternionType; |
| 92 |
|
|
| 93 |
|
/** Versor type. */ |
| 94 |
|
typedef Versor<TScalarType> VersorType; |
| 95 |
TDA |
typedef typename VersorType::VectorType AxisType; |
| 96 |
TDA |
typedef typename VersorType::ValueType AngleType; |
| 97 |
|
|
| 98 |
|
/** Get offset of an Rigid3DPerspectiveTransform |
| 99 |
|
* This method returns the value of the offset of the |
| 100 |
|
* Rigid3DPerspectiveTransform. */ |
| 101 |
|
const OffsetType & GetOffset() const |
| 102 |
|
{ return m_Offset; } |
| 103 |
|
|
| 104 |
|
/** Get rotation from an Rigid3DPerspectiveTransform. |
| 105 |
|
* This method returns the value of the rotation of the |
| 106 |
|
* Rigid3DPerspectiveTransform. */ |
| 107 |
|
const VersorType & GetRotation() const |
| 108 |
|
{ return m_Versor; } |
| 109 |
|
|
| 110 |
|
/** Set/Get the transformation from a container of parameters. |
| 111 |
|
* This is typically used by optimizers. |
| 112 |
|
* There are 6 parameters. The first three represent the |
| 113 |
|
* versor and the last three represents the offset. */ |
| 114 |
|
void SetParameters( const ParametersType & parameters ); |
| 115 |
|
const ParametersType & GetParameters() const; |
| 116 |
|
|
| 117 |
|
/** This method sets the offset of an Rigid3DPerspectiveTransform to a |
| 118 |
|
* value specified by the user. */ |
| 119 |
|
void SetOffset(const OffsetType &offset) |
| 120 |
|
{ m_Offset = offset; return; } |
| 121 |
|
|
| 122 |
|
/** This method sets the rotation of an Rigid3DPerspectiveTransform to a |
| 123 |
|
* value specified by the user. */ |
| 124 |
|
void SetRotation(const VersorType &rotation); |
| 125 |
|
|
| 126 |
|
/** Set Rotation of the Rigid transform. |
| 127 |
|
* This method sets the rotation of an Rigid3DTransform to a |
| 128 |
|
* value specified by the user using the axis of rotation an |
| 129 |
|
* the angle. */ |
| 130 |
|
void SetRotation(const Vector<TScalarType,3> &axis, double angle); |
| 131 |
|
|
| 132 |
|
/** Set the Focal Distance of the projection |
| 133 |
|
* This method sets the focal distance for the perspective |
| 134 |
|
* projection to a value specified by the user. */ |
| 135 |
|
void SetFocalDistance( TScalarType focalDistance ) |
| 136 |
|
{ m_FocalDistance = focalDistance; } |
| 137 |
|
|
| 138 |
|
/** Return the Focal Distance */ |
| 139 |
|
double GetFocalDistance( void ) const |
| 140 |
|
{ return m_FocalDistance; } |
| 141 |
|
|
| 142 |
|
/** Transform by a Rigid3DPerspectiveTransform. This method |
| 143 |
|
* applies the transform given by self to a |
| 144 |
|
* given point, returning the transformed point. */ |
| 145 |
|
OutputPointType TransformPoint(const InputPointType &point ) const; |
| 146 |
|
|
| 147 |
|
/** Return the rotation matrix */ |
| 148 |
|
const MatrixType & GetRotationMatrix() const {return m_RotationMatrix;} |
| 149 |
|
|
| 150 |
|
/** Compute the matrix. */ |
| 151 |
|
void ComputeMatrix(void); |
| 152 |
|
|
| 153 |
|
/** Compute the Jacobian Matrix of the transformation at one point */ |
| 154 |
|
virtual const JacobianType & GetJacobian(const InputPointType &point ) const; |
| 155 |
|
|
| 156 |
|
/** Set a fixed offset: this allow to center the object to be transformed */ |
| 157 |
|
itkGetConstReferenceMacro(FixedOffset,OffsetType); |
| 158 |
|
itkSetMacro(FixedOffset,OffsetType); |
| 159 |
|
|
| 160 |
|
/** Set the center of Rotation */ |
| 161 |
|
itkSetMacro(CenterOfRotation,InputPointType); |
| 162 |
|
itkGetConstReferenceMacro(CenterOfRotation,InputPointType); |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
protected: |
| 166 |
IND |
****Rigid3DPerspectiveTransform(); |
| 167 |
IND |
****~Rigid3DPerspectiveTransform(); |
| 168 |
IND |
****void PrintSelf(std::ostream &os, Indent indent) const; |
| 169 |
|
|
| 170 |
|
private: |
| 171 |
|
Rigid3DPerspectiveTransform(const Self&); //purposely not implemented |
| 172 |
|
void operator=(const Self&); //purposely not implemented |
| 173 |
|
|
| 174 |
|
/** Offset of the transformation. */ |
| 175 |
|
OffsetType m_Offset; |
| 176 |
|
|
| 177 |
|
/** Rotation of the transformation. */ |
| 178 |
|
VersorType m_Versor; |
| 179 |
|
|
| 180 |
|
/** Set Focal distance of the projection. */ |
| 181 |
|
TScalarType m_FocalDistance; |
| 182 |
|
|
| 183 |
|
/** Matrix representation of the rotation. */ |
| 184 |
|
MatrixType m_RotationMatrix; |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
/** Fixed offset*/ |
| 188 |
|
OffsetType m_FixedOffset; |
| 189 |
|
|
| 190 |
|
/** Center of rotation */ |
| 191 |
|
InputPointType m_CenterOfRotation; |
| 192 |
|
|
| 193 |
|
|
| 194 |
|
}; //class Rigid3DPerspectiveTransform: |
| 195 |
|
|
| 196 |
|
|
| 197 |
EML |
|
| 198 |
|
} // namespace itk |
| 199 |
|
|
| 200 |
|
|
| 201 |
|
#ifndef ITK_MANUAL_INSTANTIATION |
| 202 |
|
#include "itkRigid3DPerspectiveTransform.txx" |
| 203 |
|
#endif |
| 204 |
|
|
| 205 |
|
#endif /* __itkRigid3DPerspectiveTransform_h */ |
| 206 |
|
|