ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkQuaternionRigidTransform.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkQuaternionRigidTransform_h
00019 #define __itkQuaternionRigidTransform_h
00020 
00021 #include <iostream>
00022 #include "itkRigid3DTransform.h"
00023 #include "vnl/vnl_quaternion.h"
00024 
00025 namespace itk
00026 {
00047 template <class TScalarType = double>
00048 // Data type for scalars (float or double)
00049 class ITK_EXPORT QuaternionRigidTransform :
00050   public Rigid3DTransform<TScalarType>
00051 {
00052 public:
00054   typedef QuaternionRigidTransform      Self;
00055   typedef Rigid3DTransform<TScalarType> Superclass;
00056   typedef SmartPointer<Self>            Pointer;
00057   typedef SmartPointer<const Self>      ConstPointer;
00058 
00060   itkNewMacro(Self);
00061 
00063   itkTypeMacro(QuaternionRigidTransform, Rigid3DTransform);
00064 
00066   itkStaticConstMacro(InputSpaceDimension, unsigned int, 3);
00067   itkStaticConstMacro(OutputSpaceDimension, unsigned int, 3);
00068   itkStaticConstMacro(SpaceDimension, unsigned int, 3);
00069   itkStaticConstMacro(ParametersDimension, unsigned int, 7);
00071 
00073   typedef typename Superclass::ParametersType            ParametersType;
00074   typedef typename Superclass::ParametersValueType       ParametersValueType;
00075   typedef typename Superclass::JacobianType              JacobianType;
00076   typedef typename Superclass::ScalarType                ScalarType;
00077   typedef typename Superclass::InputPointType            InputPointType;
00078   typedef typename Superclass::OutputPointType           OutputPointType;
00079   typedef typename Superclass::InputVectorType           InputVectorType;
00080   typedef typename Superclass::OutputVectorType          OutputVectorType;
00081   typedef typename Superclass::OutputVectorValueType     OutputVectorValueType;
00082   typedef typename Superclass::InputVnlVectorType        InputVnlVectorType;
00083   typedef typename Superclass::OutputVnlVectorType       OutputVnlVectorType;
00084   typedef typename Superclass::InputCovariantVectorType  InputCovariantVectorType;
00085   typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
00086   typedef typename Superclass::MatrixType                MatrixType;
00087   typedef typename Superclass::InverseMatrixType         InverseMatrixType;
00088   typedef typename Superclass::CenterType                CenterType;
00089   typedef typename Superclass::OffsetType                OffsetType;
00090   typedef typename Superclass::TranslationType           TranslationType;
00091 
00093   typedef vnl_quaternion<TScalarType> VnlQuaternionType;
00094 
00100   void SetRotation(const VnlQuaternionType & rotation);
00101 
00105   const VnlQuaternionType & GetRotation(void) const
00106   {
00107     return m_Rotation;
00108   }
00109 
00111   virtual void SetIdentity(void);
00112 
00118   void SetParameters(const ParametersType & parameters);
00119 
00120   virtual const ParametersType & GetParameters() const;
00121 
00127   virtual void ComputeJacobianWithRespectToParameters( const InputPointType  & p, JacobianType & jacobian) const;
00128 
00129 protected:
00130   QuaternionRigidTransform(const MatrixType & matrix, const OutputVectorType & offset);
00131   QuaternionRigidTransform(unsigned int paramDims);
00132   QuaternionRigidTransform();
00133   ~QuaternionRigidTransform()
00134   {
00135   }
00136 
00137   void ComputeMatrix();
00138 
00139   void ComputeMatrixParameters();
00140 
00141   void SetVarRotation(const VnlQuaternionType & rotation)
00142   {
00143     m_Rotation = rotation;
00144   }
00145 
00146   const InverseMatrixType & GetInverseMatrix(void) const;
00147 
00148   void PrintSelf(std::ostream & os, Indent indent) const;
00149 
00150 private:
00151   QuaternionRigidTransform(const Self &); // purposely not implemented
00152   void operator=(const Self &);           // purposely not implemented
00153 
00155   VnlQuaternionType m_Rotation;
00156 }; // class QuaternionRigidTransform
00157 }  // namespace itk
00158 
00159 // Define instantiation macro for this template.
00160 #define ITK_TEMPLATE_QuaternionRigidTransform(_, EXPORT, TypeX, TypeY)     \
00161   namespace itk                                                            \
00162   {                                                                        \
00163   _( 1 ( class EXPORT QuaternionRigidTransform<ITK_TEMPLATE_1 TypeX> ) ) \
00164   namespace Templates                                                      \
00165   {                                                                        \
00166   typedef QuaternionRigidTransform<ITK_TEMPLATE_1 TypeX>                 \
00167   QuaternionRigidTransform##TypeY;                                       \
00168   }                                                                        \
00169   }
00170 
00171 #if ITK_TEMPLATE_EXPLICIT
00172 #include "Templates/itkQuaternionRigidTransform+-.h"
00173 #endif
00174 
00175 #if ITK_TEMPLATE_TXX
00176 #include "itkQuaternionRigidTransform.hxx"
00177 #endif
00178 
00179 #endif /* __itkQuaternionRigidTransform_h */
00180