3D affine transformation. More...
#include <cmtkAffineXform.h>
Public Types | |
typedef AffineXform | Self |
This class type. | |
typedef Xform | Superclass |
Superclass type. | |
typedef SmartPointer< Self > | SmartPtr |
Smart pointer to AffineXform. | |
typedef SmartConstPointer< Self > | SmartConstPtr |
Smart pointer to const AffineXform. | |
typedef Matrix4x4 < Types::Coordinate > | MatrixType |
Transformation matrix.type. | |
Public Member Functions | |
void | MakeIdentityXform () |
Create identity transformation. | |
Self::SpaceVectorType | RotateScaleShear (const Self::SpaceVectorType &v) const |
Apply rotation, scaling, and shearing but no translation to vector. | |
AffineXform () | |
Create identity transformation. | |
AffineXform (const CoordinateVector &v, const bool logScaleFactors=false) | |
Create transformation from parameter vector. | |
AffineXform (const Types::Coordinate v[15], const bool logScaleFactors=false) | |
Create transformation from raw parameter array. | |
AffineXform (const Types::Coordinate matrix[4][4], const Types::Coordinate *center=NULL) | |
Create transformation from transformation matrix. | |
AffineXform (const MatrixType &matrix, const Types::Coordinate *center=NULL) | |
Create transformation from transformation matrix. | |
AffineXform (const Types::Coordinate matrix[4][4], const Types::Coordinate xlate[3], const Types::Coordinate center[3]) | |
Create transformation from transformation matrix. | |
AffineXform (const AffineXform &other) | |
Copy transform by reference. | |
virtual | ~AffineXform () |
Virtual destructor. | |
Self::SmartPtr | Clone () const |
Clone and return smart pointer. | |
virtual Self * | MakeInverse () const |
Clone inverse of this transformation. | |
virtual Self::SmartPtr | GetDifference (const AffineXform &other) const |
Compute difference to another affine transformation. | |
const Self::SmartPtr | GetInverse () const |
Get linked inverse of this transformation. | |
virtual Types::Coordinate | GetGlobalScaling () const |
Get global scaling factor. | |
virtual Types::Coordinate | GetJacobianDeterminant (const Self::SpaceVectorType &) const |
Compute Jacobian determinant at a certain location. | |
void | Concat (const AffineXform &other) |
Concatenate this transformation with another. | |
void | Insert (const AffineXform &other) |
Insert another transformation before this one. | |
void | RotateWXYZ (const Units::Radians angle, const Self::SpaceVectorType &direction, const Types::Coordinate *origin=NULL, Self::MatrixType *const accumulate=NULL) |
Rotate around axis. | |
void | ChangeCoordinateSystem (const Self::SpaceVectorType &newX, const Self::SpaceVectorType &newY) |
Change transformation coordinate system. | |
virtual Self::SpaceVectorType | Apply (const Self::SpaceVectorType &vec) const |
Apply transformation to vector. | |
void | ApplyInPlace (Self::SpaceVectorType &vec) const |
Apply transformation to existing vector. | |
virtual bool | ApplyInverse (const Self::SpaceVectorType &v, Self::SpaceVectorType &u, const Types::Coordinate=0.01) const |
Return origin of warped vector. | |
virtual bool | ApplyInverseInPlace (Self::SpaceVectorType &v, const Types::Coordinate=0.01) const |
Return origin of warped vector. | |
void | ChangeCenter (const Self::SpaceVectorType ¢er) |
Create equivalent transformation with different rotational center. | |
virtual size_t | ParamVectorDim () const |
Get dimension of parameter vector. | |
virtual size_t | VariableParamVectorDim () const |
Get dimension of variable parameter vector. | |
virtual void | SetNumberDOFs (const int numberDOFs=12) |
Set the number of degrees of freedom for this object. | |
virtual unsigned int | GetNumberDOFs () const |
Get the number of degrees of freedom for this object. | |
bool | GetUseLogScaleFactors () const |
Return flag for log scale factors. | |
void | SetUseLogScaleFactors (const bool logScaleFactors) |
Switch between log and ordinary scale factors. | |
virtual void | SetParamVector (CoordinateVector &v) |
Set Xform by parameter vector. | |
virtual void | SetParamVector (const CoordinateVector &v) |
Set Xform by constant parameter vector. | |
virtual void | SetParameter (const size_t idx, const Types::Coordinate p) |
Set a single parameter value. | |
virtual Types::Coordinate | GetParamStep (const size_t idx, const Self::SpaceVectorType &volSize, const Types::Coordinate step_mm=1) const |
Get parameter stepping. | |
AffineXform & | operator= (const AffineXform &other) |
Assignment operator. | |
virtual void | Print () const |
Print object. | |
template<> | |
void | GetMatrix (float(&matrix)[4][4]) const |
template<> | |
void | GetMatrix (double(&matrix)[4][4]) const |
Read-only parameter retrieval. | |
const Types::Coordinate * | RetXlate () const |
Return pointer to translation parameters. | |
const Types::Coordinate * | RetAngles () const |
Return pointer to rotation angles. | |
const Types::Coordinate * | RetScales () const |
Return pointer to scaling factors. | |
const Types::Coordinate * | RetShears () const |
Return pointer to shear coefficients. | |
const Types::Coordinate * | RetCenter () const |
Return pointer to center of rotation, scaling, and shearing. | |
Modifyable parameter retrieval. | |
Types::Coordinate * | RetXlate () |
Return pointer to translation parameters. | |
Types::Coordinate * | RetAngles () |
Return pointer to rotation angles. | |
Types::Coordinate * | RetScales () |
Return pointer to scaling factors. | |
Types::Coordinate * | RetShears () |
Return pointer to shear coefficients. | |
Types::Coordinate * | RetCenter () |
Return pointer to center of rotation, scaling, and shearing. | |
Direct parameter modifications. | |
void | SetXlate (const Types::Coordinate *xlate) |
Set transformation's translation vector. | |
void | SetXlate (const Types::Coordinate dx, const Types::Coordinate dy, const Types::Coordinate dz) |
Set transformation's translation vector. | |
void | Translate (const Types::Coordinate dx, const Types::Coordinate dy, const Types::Coordinate dz) |
Add to transformation's translation vector. | |
void | Translate (const Self::SpaceVectorType &delta) |
Add to transformation's translation vector. | |
void | SetAngles (const Types::Coordinate *angles) |
Set transformation's rotation angles. | |
template<class T > | |
void | GetScales (T(&scales)[3]) const |
Get scale factors with implicit conversion of log scales. | |
void | SetScales (const Types::Coordinate *scales) |
Set transformation's scaling factors. | |
void | SetScales (const Types::Coordinate sx, const Types::Coordinate sy, const Types::Coordinate sz) |
Set transformation's scaling factors. | |
void | SetShears (const Types::Coordinate *shears) |
Set transformation's shears. | |
void | SetCenter (const Types::Coordinate *center) |
Set transformation's rotation, scaling, and shearing center. | |
Matrix access. | |
const Types::Coordinate * | RetMatrix () const |
Return transformation matrix. | |
Types::Coordinate * | RetMatrix () |
Return transformation matrix. | |
void | SetMatrix (const float matrix[4][4]) |
Set transformation matrix. | |
void | SetMatrix (const double matrix[4][4]) |
void | SetMatrix (const MatrixType &matrix) |
template<class T > | |
void | GetMatrix (T(&matrix)[4][4]) const |
Get transformation matrix. | |
Public Attributes | |
Self::MatrixType | Matrix |
Homogeneous transformation matrix. | |
Static Public Attributes | |
static const size_t | TotalNumberOfParameters = 15 |
Total number of parameters. | |
Protected Member Functions | |
virtual Self * | CloneVirtual () const |
Clone this object. | |
void | ComposeMatrix () |
Compose this object's transformation matrix from parameter vector. | |
bool | DecomposeMatrix () |
Decompose this object's transformation matrix into parameter vector. | |
Protected Attributes | |
int | NumberDOFs |
Actual number of degrees of freedom. | |
Private Member Functions | |
void | UpdateInverse () const |
Update linked inverse transformation. | |
void | SetMatrixDirect (const Types::Coordinate *matrix) |
Set transformation matrix. | |
void | CanonicalRotationRange () |
Correct rotation parameters to canonical range -180 to 180. | |
Static Private Member Functions | |
static int | DefaultNumberOfDOFs () |
Return the default number of degrees of freedom. | |
Private Attributes | |
bool | m_LogScaleFactors |
Flag for logarithmic vs. ordinary scale factors. | |
Self::SmartPtr | InverseXform |
Link to an auto-updated inverse transformation. |
3D affine transformation.
This transformation class allows translations, rotations, componentwise scalings, and shears. Transformation is done by vector-matrix-multiplication with a homogeneous 4x4 matrix. The transformation can be defined by either the matrix itself or a parameter vector. Both representations are permanently accessible and held mutually up-to-date whenever one of them changes.
Definition at line 63 of file cmtkAffineXform.h.
Transformation matrix.type.
Definition at line 81 of file cmtkAffineXform.h.
typedef AffineXform cmtk::AffineXform::Self |
Smart pointer to const AffineXform.
Reimplemented from cmtk::Xform.
Definition at line 78 of file cmtkAffineXform.h.
typedef SmartPointer<Self> cmtk::AffineXform::SmartPtr |
Smart pointer to AffineXform.
Reimplemented from cmtk::Xform.
Definition at line 75 of file cmtkAffineXform.h.
typedef Xform cmtk::AffineXform::Superclass |
Superclass type.
Definition at line 72 of file cmtkAffineXform.h.
cmtk::AffineXform::AffineXform | ( | ) | [inline] |
Create identity transformation.
Definition at line 113 of file cmtkAffineXform.h.
Referenced by MakeInverse().
cmtk::AffineXform::AffineXform | ( | const CoordinateVector & | v, |
const bool | logScaleFactors = false |
||
) | [inline] |
Create transformation from parameter vector.
v | The parameter vector defining the desired transformation. Refer to 'Parameters' for a detailed description. |
logScaleFactors | Flag for using log scale factors instead of plain scale factors. |
Definition at line 124 of file cmtkAffineXform.h.
cmtk::AffineXform::AffineXform | ( | const Types::Coordinate | v[15], |
const bool | logScaleFactors = false |
||
) | [inline] |
Create transformation from raw parameter array.
v | The parameter vector defining the desired transformation. Refer to 'Parameters' for a detailed description. |
logScaleFactors | Flag for using log scale factors instead of plain scale factors. |
Definition at line 136 of file cmtkAffineXform.h.
virtual cmtk::AffineXform::~AffineXform | ( | ) | [inline, virtual] |
Virtual destructor.
Frees the linked inverse transformation if one exists.
Definition at line 181 of file cmtkAffineXform.h.
virtual Self::SpaceVectorType cmtk::AffineXform::Apply | ( | const Self::SpaceVectorType & | vec ) | const [inline, virtual] |
Apply transformation to vector.
Implements cmtk::Xform.
Definition at line 254 of file cmtkAffineXform.h.
void cmtk::AffineXform::ApplyInPlace | ( | Self::SpaceVectorType & | vec ) | const [inline, virtual] |
Apply transformation to existing vector.
Implements cmtk::Xform.
Definition at line 262 of file cmtkAffineXform.h.
Referenced by cmtk::AffineXformUniformVolume::AffineXformUniformVolume(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::ComputeErrorGradientImage(), cmtk::WarpXform::ConcatAffine(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::GetPassImageDependentPixelRegion(), cmtk::SplineWarpXform::InitControlPoints(), cmtk::DeformationField::InitControlPoints(), cmtk::GroupwiseRegistrationFunctionalXformTemplate< AffineXform >::InterpolateImageProbabilisticThread(), cmtk::InverseInterpolationVolumeReconstruction< TInterpolator >::Interpolation(), cmtk::WarpXform::ReplaceInitialAffine(), cmtk::TransformedVolumeAxes::TransformedVolumeAxes(), and cmtk::VolumeInjectionReconstruction::VolumeInjectionIsotropic().
virtual bool cmtk::AffineXform::ApplyInverse | ( | const Self::SpaceVectorType & | v, |
Self::SpaceVectorType & | u, | ||
const Types::Coordinate | = 0.01 |
||
) | const [inline, virtual] |
Return origin of warped vector.
Implements cmtk::Xform.
Definition at line 269 of file cmtkAffineXform.h.
virtual bool cmtk::AffineXform::ApplyInverseInPlace | ( | Self::SpaceVectorType & | v, |
const Types::Coordinate | = 0.01 |
||
) | const [inline, virtual] |
Return origin of warped vector.
Implements cmtk::Xform.
Definition at line 277 of file cmtkAffineXform.h.
void cmtk::AffineXform::ChangeCoordinateSystem | ( | const Self::SpaceVectorType & | newX, |
const Self::SpaceVectorType & | newY | ||
) | [inline] |
Change transformation coordinate system.
Definition at line 247 of file cmtkAffineXform.h.
Self::SmartPtr cmtk::AffineXform::Clone | ( | ) | const [inline] |
Clone and return smart pointer.
Reimplemented from cmtk::Xform.
Definition at line 187 of file cmtkAffineXform.h.
Referenced by cmtk::SplineWarpXform::Init(), cmtk::WarpXform::ReplaceInitialAffine(), and cmtk::SplineWarpXform::SplineWarpXform().
virtual Self* cmtk::AffineXform::CloneVirtual | ( | ) | const [inline, protected, virtual] |
static int cmtk::AffineXform::DefaultNumberOfDOFs | ( | ) | [inline, static, private] |
Return the default number of degrees of freedom.
Definition at line 507 of file cmtkAffineXform.h.
virtual Types::Coordinate cmtk::AffineXform::GetGlobalScaling | ( | ) | const [inline, virtual] |
Get global scaling factor.
Reimplemented from cmtk::Xform.
Definition at line 204 of file cmtkAffineXform.h.
Referenced by cmtk::SplineWarpXform::InitControlPoints(), and cmtk::DeformationField::InitControlPoints().
virtual Types::Coordinate cmtk::AffineXform::GetJacobianDeterminant | ( | const Self::SpaceVectorType & | ) | const [inline, virtual] |
Compute Jacobian determinant at a certain location.
For an affine transformation, the Jacobian determinant is the product of the anisotropic scale factors at any location.
Implements cmtk::Xform.
Definition at line 220 of file cmtkAffineXform.h.
void cmtk::AffineXform::GetMatrix | ( | T(&) | matrix[4][4] ) | const |
Get transformation matrix.
virtual unsigned int cmtk::AffineXform::GetNumberDOFs | ( | ) | const [inline, virtual] |
Get the number of degrees of freedom for this object.
Definition at line 443 of file cmtkAffineXform.h.
void cmtk::AffineXform::GetScales | ( | T(&) | scales[3] ) | const [inline] |
Get scale factors with implicit conversion of log scales.
Definition at line 355 of file cmtkAffineXform.h.
Referenced by cmtk::SplineWarpXform::InitControlPoints(), and cmtk::DeformationField::InitControlPoints().
bool cmtk::AffineXform::GetUseLogScaleFactors | ( | ) | const [inline] |
Return flag for log scale factors.
Definition at line 446 of file cmtkAffineXform.h.
Referenced by cmtk::operator<<().
virtual size_t cmtk::AffineXform::ParamVectorDim | ( | ) | const [inline, virtual] |
Get dimension of parameter vector.
Reimplemented from cmtk::Xform.
Definition at line 432 of file cmtkAffineXform.h.
const Types::Coordinate* cmtk::AffineXform::RetAngles | ( | ) | const [inline] |
Return pointer to rotation angles.
Definition at line 289 of file cmtkAffineXform.h.
Referenced by cmtk::MakeInitialAffineTransformation::AlignPrincipalAxes(), and cmtk::operator<<().
Types::Coordinate* cmtk::AffineXform::RetAngles | ( | ) | [inline] |
Return pointer to rotation angles.
Definition at line 304 of file cmtkAffineXform.h.
const Types::Coordinate* cmtk::AffineXform::RetCenter | ( | ) | const [inline] |
Return pointer to center of rotation, scaling, and shearing.
Definition at line 295 of file cmtkAffineXform.h.
Referenced by ChangeCenter(), DecomposeMatrix(), MakeInverse(), and cmtk::operator<<().
Types::Coordinate* cmtk::AffineXform::RetCenter | ( | ) | [inline] |
Return pointer to center of rotation, scaling, and shearing.
Definition at line 310 of file cmtkAffineXform.h.
const Types::Coordinate* cmtk::AffineXform::RetMatrix | ( | ) | const [inline] |
Return transformation matrix.
Definition at line 410 of file cmtkAffineXform.h.
Types::Coordinate* cmtk::AffineXform::RetMatrix | ( | ) | [inline] |
Return transformation matrix.
Definition at line 413 of file cmtkAffineXform.h.
Types::Coordinate* cmtk::AffineXform::RetScales | ( | ) | [inline] |
Return pointer to scaling factors.
Definition at line 306 of file cmtkAffineXform.h.
const Types::Coordinate* cmtk::AffineXform::RetScales | ( | ) | const [inline] |
Return pointer to scaling factors.
Definition at line 291 of file cmtkAffineXform.h.
Referenced by cmtk::operator<<().
const Types::Coordinate* cmtk::AffineXform::RetShears | ( | ) | const [inline] |
Return pointer to shear coefficients.
Definition at line 293 of file cmtkAffineXform.h.
Referenced by cmtk::operator<<().
Types::Coordinate* cmtk::AffineXform::RetShears | ( | ) | [inline] |
Return pointer to shear coefficients.
Definition at line 308 of file cmtkAffineXform.h.
const Types::Coordinate* cmtk::AffineXform::RetXlate | ( | ) | const [inline] |
Return pointer to translation parameters.
Definition at line 287 of file cmtkAffineXform.h.
Referenced by ChangeCenter(), and cmtk::operator<<().
Types::Coordinate* cmtk::AffineXform::RetXlate | ( | ) | [inline] |
Return pointer to translation parameters.
Definition at line 302 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetAngles | ( | const Types::Coordinate * | angles ) | [inline] |
Set transformation's rotation angles.
Definition at line 347 of file cmtkAffineXform.h.
Referenced by cmtk::MakeInitialAffineTransformation::AlignPrincipalAxes(), and cmtk::ParametricPlane::GetAlignmentXform().
void cmtk::AffineXform::SetCenter | ( | const Types::Coordinate * | center ) | [inline] |
Set transformation's rotation, scaling, and shearing center.
Definition at line 397 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetMatrixDirect | ( | const Types::Coordinate * | matrix ) | [inline, private] |
Set transformation matrix.
Other than the plain SetMatrix() function, this implementation DOES NOT also update the associated inverse transformation. Therefore, it may safely be called by all other SetXXX() functions in order to update the inverse transformation without producing an infinite loop.
Definition at line 521 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetScales | ( | const Types::Coordinate | sx, |
const Types::Coordinate | sy, | ||
const Types::Coordinate | sz | ||
) | [inline] |
Set transformation's scaling factors.
Definition at line 382 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetScales | ( | const Types::Coordinate * | scales ) | [inline] |
Set transformation's scaling factors.
Definition at line 374 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetShears | ( | const Types::Coordinate * | shears ) | [inline] |
Set transformation's shears.
Definition at line 389 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetXlate | ( | const Types::Coordinate | dx, |
const Types::Coordinate | dy, | ||
const Types::Coordinate | dz | ||
) | [inline] |
Set transformation's translation vector.
Definition at line 325 of file cmtkAffineXform.h.
void cmtk::AffineXform::SetXlate | ( | const Types::Coordinate * | xlate ) | [inline] |
Set transformation's translation vector.
Definition at line 317 of file cmtkAffineXform.h.
Referenced by cmtk::MakeInitialAffineTransformation::AlignCentersOfMass(), cmtk::MakeInitialAffineTransformation::AlignFieldsOfView(), and cmtk::ParametricPlane::GetAlignmentXform().
void cmtk::AffineXform::Translate | ( | const Self::SpaceVectorType & | delta ) | [inline] |
Add to transformation's translation vector.
Definition at line 339 of file cmtkAffineXform.h.
void cmtk::AffineXform::Translate | ( | const Types::Coordinate | dx, |
const Types::Coordinate | dy, | ||
const Types::Coordinate | dz | ||
) | [inline] |
Add to transformation's translation vector.
Definition at line 332 of file cmtkAffineXform.h.
virtual size_t cmtk::AffineXform::VariableParamVectorDim | ( | ) | const [inline, virtual] |
Get dimension of variable parameter vector.
The rotation center is not considered variable, therefore 6 is returned.
Reimplemented from cmtk::Xform.
Definition at line 437 of file cmtkAffineXform.h.
Self::SmartPtr cmtk::AffineXform::InverseXform [mutable, private] |
Link to an auto-updated inverse transformation.
Definition at line 510 of file cmtkAffineXform.h.
Referenced by GetInverse(), and UpdateInverse().
bool cmtk::AffineXform::m_LogScaleFactors [private] |
Flag for logarithmic vs. ordinary scale factors.
Definition at line 504 of file cmtkAffineXform.h.
Referenced by AffineXform(), ComposeMatrix(), DecomposeMatrix(), MakeInverse(), operator=(), SetUseLogScaleFactors(), and UpdateInverse().
Homogeneous transformation matrix.
Vectors are transformed by right-multiplication with this matrix, i.e. v being a vector, the transformed vector is (v Matrix).
Definition at line 90 of file cmtkAffineXform.h.
Referenced by Concat(), Insert(), MakeInverse(), cmtk::TransformChangeFromSpaceAffine::TransformChangeFromSpaceAffine(), cmtk::TransformChangeToSpaceAffine::TransformChangeToSpaceAffine(), and cmtk::AffineXformITKIO::Write().
int cmtk::AffineXform::NumberDOFs [protected] |
Actual number of degrees of freedom.
This value should be one out of four choices: 6 (rigid transformation), 7 (rigid with global scaling), 9 (rigid with componentwise scaling), or 12 (full affine). The number of elements of the parameter vector does NOT change, even in the 7 DOF case. Then, all scaling factors are simply kept equal.
Definition at line 500 of file cmtkAffineXform.h.
Referenced by AffineXform(), ComposeMatrix(), MakeInverse(), operator=(), Print(), SetNumberDOFs(), and UpdateInverse().
const size_t cmtk::AffineXform::TotalNumberOfParameters = 15 [static] |
Total number of parameters.
The values stored in the parameter vector are: Three translations (x, y, z), three rotation angles (around x-, y-, and z-axis) in degrees, three scaling factors (x-, y-, and z-direction), and three shears. The last three values define the center of rotation, scaling, and shearing.
Definition at line 99 of file cmtkAffineXform.h.
Referenced by AffineXform().