KWStyle - itkCenteredEuler3DTransform.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkCenteredEuler3DTransform.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
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 DEF #ifndef _itkCenteredEuler3DTransform_txx
18 DEF #define _itkCenteredEuler3DTransform_txx
19
20 #include "itkCenteredEuler3DTransform.h"
21
22
23 namespace itk
24 {
25
26 // Constructor with default arguments
27 template<class TScalarType>
28 CenteredEuler3DTransform<TScalarType>::
29 CenteredEuler3DTransform() :
30 IND **Superclass(OutputSpaceDimension, ParametersDimension)
31 {
32 }
33  
34 // Constructor with default arguments
35 template<class TScalarType>
36 CenteredEuler3DTransform<TScalarType>::
37 CenteredEuler3DTransform(unsigned int spaceDimension, 
38                          unsigned int parametersDimension) :
39 IND **Superclass(spaceDimension,parametersDimension)
40 {
41 }
42
43 // Constructor with default arguments
44 template<class TScalarType>
45 CenteredEuler3DTransform<TScalarType>::
46 CenteredEuler3DTransform(const MatrixType & matrix,
47                          const OutputVectorType & offset) :
48 IND **Superclass(matrix, offset)
49 {
50 }
51
52
53 // Destructor
54 template<class TScalarType>
55 CenteredEuler3DTransform<TScalarType>::
56 ~CenteredEuler3DTransform()
57 {
58 }
59
60
61 //
62 // Set Parameters
63 // 
64 // Parameters are ordered as:
65 //
66 // p[0:2] = rotations about x, y and z axes
67 // p[3:5} = center of rotation
68 // p[6:8] = translation
69 //
70 //
71 template <class TScalarType>
72 void
73 CenteredEuler3DTransform<TScalarType>
74 ::SetParameters( const ParametersType & parameters )
75 {
76   itkDebugMacro( << "Setting paramaters " << parameters );
77
78   this->SetVarRotation(parameters[0], parameters[1], parameters[2]);
79
80   CenterType newCenter;
81   newCenter[0] = parameters[3];
82   newCenter[1] = parameters[4];
83   newCenter[2] = parameters[5];
84   this->SetVarCenter(newCenter);
85   this->ComputeMatrix();
86
87   TranslationType newTranslation;
88   newTranslation[0] = parameters[6];
89   newTranslation[1] = parameters[7];
90   newTranslation[2] = parameters[8];
91   this->SetVarTranslation(newTranslation);
92   this->ComputeOffset();
93
94   itkDebugMacro(<<"After setting parameters ");
95 }
96
97 //
98 // Get Parameters
99 // 
100 // Parameters are ordered as:
101 //
102 // p[0:2] = rotations about x, y and z axes
103 // p[3:5} = center of rotation
104 // p[6:8] = translation
105 //
106
107 template <class TScalarType>
108 IND const typename CenteredEuler3DTransform<TScalarType>::ParametersType &
109 IND CenteredEuler3DTransform<TScalarType>
110 IND ::GetParameters( void ) const
111 IND {
112 IND **ParametersType parameters;
113
114 IND **this->m_Parameters[0] = this->GetAngleX();
115 IND **this->m_Parameters[1] = this->GetAngleY();
116 IND **this->m_Parameters[2] = this->GetAngleZ();
117
118 IND **this->m_Parameters[3] = this->GetCenter()[0];
119 IND **this->m_Parameters[4] = this->GetCenter()[1];
120 IND **this->m_Parameters[5] = this->GetCenter()[2];
121
122 IND **this->m_Parameters[6] = this->GetTranslation()[0];
123 IND **this->m_Parameters[7] = this->GetTranslation()[1];
124 IND **this->m_Parameters[8] = this->GetTranslation()[2];
125
126 IND **return this->m_Parameters;
127 IND }
128
129
130 IND // Get jacobian
131 IND template<class TScalarType>
132 IND const typename Euler3DTransform<TScalarType>::JacobianType &
133 IND CenteredEuler3DTransform<TScalarType>::
134 IND GetJacobian( const InputPointType & p ) const
135 IND {
136 IND **// need to check if angles are in the right order
137 IND **const double cx = cos(this->GetAngleX());
138 IND **const double sx = sin(this->GetAngleX());
139 IND **const double cy = cos(this->GetAngleY());
140 IND **const double sy = sin(this->GetAngleY()); 
141 IND **const double cz = cos(this->GetAngleZ());
142 IND **const double sz = sin(this->GetAngleZ());
143
144 IND **this->m_Jacobian.Fill(0.0);
145
146 IND **const double px = p[0] - this->GetCenter()[0];
147 IND **const double py = p[1] - this->GetCenter()[1];
148 IND **const double pz = p[2] - this->GetCenter()[2];
149
150
151 IND **if ( this->GetComputeZYX() )
152 IND ****{
153 IND ****this->m_Jacobian[0][0] = (cz*sy*cx+sz*sx)*py+(-cz*sy*sx+sz*cx)*pz;
154 IND ****this->m_Jacobian[1][0] = (sz*sy*cx-cz*sx)*py+(-sz*sy*sx-cz*cx)*pz;
155 IND ****this->m_Jacobian[2][0] = (cy*cx)*py+(-cy*sx)*pz;  
156     
157 IND ****this->m_Jacobian[0][1] = (-cz*sy)*px+(cz*cy*sx)*py+(cz*cy*cx)*pz;
158 IND ****this->m_Jacobian[1][1] = (-sz*sy)*px+(sz*cy*sx)*py+(sz*cy*cx)*pz;
159 IND ****this->m_Jacobian[2][1] = (-cy)*px+(-sy*sx)*py+(-sy*cx)*pz;
160     
161 IND ****this->m_Jacobian[0][2] = (-sz*cy)*px+(-sz*sy*sx-cz*cx)*py
162 IND ****************************************+(-sz*sy*cx+cz*sx)*pz;
163 LEN,IND ****this->m_Jacobian[1][2] = (cz*cy)*px+(cz*sy*sx-sz*cx)*py+(cz*sy*cx+sz*sx)*pz;  
164 IND ****this->m_Jacobian[2][2] = 0;
165 IND ****}
166 IND **else
167 IND ****{
168 IND ****this->m_Jacobian[0][0] = (-sz*cx*sy)*px + (sz*sx)*py + (sz*cx*cy)*pz;
169 IND ****this->m_Jacobian[1][0] = (cz*cx*sy)*px + (-cz*sx)*py + (-cz*cx*cy)*pz;
170 IND ****this->m_Jacobian[2][0] = (sx*sy)*px + (cx)*py + (-sx*cy)*pz;  
171     
172 IND ****this->m_Jacobian[0][1] = (-cz*sy-sz*sx*cy)*px + (cz*cy-sz*sx*sy)*pz;
173 IND ****this->m_Jacobian[1][1] = (-sz*sy+cz*sx*cy)*px + (sz*cy+cz*sx*sy)*pz;
174 IND ****this->m_Jacobian[2][1] = (-cx*cy)*px + (-cx*sy)*pz;
175     
176 IND ****this->m_Jacobian[0][2] = (-sz*cy-cz*sx*sy)*px + (-cz*cx)*py 
177 IND **************************************************+ (-sz*sy+cz*sx*cy)*pz;
178 IND ****this->m_Jacobian[1][2] = (cz*cy-sz*sx*sy)*px + (-sz*cx)*py 
179 IND *************************************************+ (cz*sy+sz*sx*cy)*pz;
180 IND ****this->m_Jacobian[2][2] = 0;
181 IND ****}
182  
183 IND **// compute derivatives for the center of rotation part
184 IND **unsigned int blockOffset = 3;  
185 IND **for(unsigned int dim=0; dim < SpaceDimension; dim++ ) 
186     {
187     this->m_Jacobian[ dim ][ blockOffset + dim ] = 1.0;
188 IND ****}
189 IND **blockOffset += SpaceDimension;
190
191 IND **// compute derivatives for the translation part
192 IND **for(unsigned int dim=0; dim < SpaceDimension; dim++ ) 
193     {
194     this->m_Jacobian[ dim ][ blockOffset + dim ] = 1.0;
195 IND ****}
196
197 IND **return this->m_Jacobian;
198 IND }
199
200
201 IND // Print self
202 IND template<class TScalarType>
203 IND void
204 IND CenteredEuler3DTransform<TScalarType>::
205 IND PrintSelf(std::ostream &os, Indent indent) const
206 IND {
207
208 IND **Superclass::PrintSelf(os,indent);
209 IND }
210
211 IND // namespace
212
213 #endif
214

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:01PM
© Kitware Inc.