MCPcopy Create free account
hub / github.com/Kitware/VTK / InternalUpdate

Method InternalUpdate

Common/Transforms/vtkLandmarkTransform.cxx:54–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52// Update the 4x4 matrix. Updates are only done as necessary.
53
54void vtkLandmarkTransform::InternalUpdate()
55{
56 vtkIdType i;
57 int j;
58
59 if (this->SourceLandmarks == nullptr || this->TargetLandmarks == nullptr)
60 {
61 this->Matrix->Identity();
62 return;
63 }
64
65 // --- compute the necessary transform to match the two sets of landmarks ---
66
67 /*
68 The solution is based on
69 Berthold K. P. Horn (1987),
70 "Closed-form solution of absolute orientation using unit quaternions,"
71 Journal of the Optical Society of America A, 4:629-642
72 */
73
74 // Original python implementation by David G. Gobbi
75
76 const vtkIdType N_PTS = this->SourceLandmarks->GetNumberOfPoints();
77 if (N_PTS != this->TargetLandmarks->GetNumberOfPoints())
78 {
79 vtkErrorMacro("Update: Source and Target Landmarks contain a different number of points");
80 return;
81 }
82
83 // -- if no points, stop here
84
85 if (N_PTS == 0)
86 {
87 this->Matrix->Identity();
88 return;
89 }
90
91 // -- find the centroid of each set --
92
93 double source_centroid[3] = { 0, 0, 0 };
94 double target_centroid[3] = { 0, 0, 0 };
95 double p[3];
96 for (i = 0; i < N_PTS; i++)
97 {
98 this->SourceLandmarks->GetPoint(i, p);
99 source_centroid[0] += p[0];
100 source_centroid[1] += p[1];
101 source_centroid[2] += p[2];
102 this->TargetLandmarks->GetPoint(i, p);
103 target_centroid[0] += p[0];
104 target_centroid[1] += p[1];
105 target_centroid[2] += p[2];
106 }
107 source_centroid[0] /= N_PTS;
108 source_centroid[1] /= N_PTS;
109 source_centroid[2] /= N_PTS;
110 target_centroid[0] /= N_PTS;
111 target_centroid[1] /= N_PTS;

Callers

nothing calls this directly

Calls 9

JacobiNFunction · 0.85
Multiply3x3Function · 0.50
sqrtFunction · 0.50
cosFunction · 0.50
sinFunction · 0.50
IdentityMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected