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

Function GenerateLineAtKnownDistance

Common/DataModel/Testing/Cxx/UnitTestLine.cxx:169–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169void GenerateLineAtKnownDistance(
170 vtkMinimalStandardRandomSequence* seq, double* a1, double* a2, double* p, double& dist)
171{
172 // Generate a line (a1,a2) set a known distance (dist) from a generated point
173 // p.
174
175 double v1[3], v2[3], v3[3];
176 for (unsigned i = 0; i < 3; i++)
177 {
178 v1[i] = seq->GetValue();
179 seq->Next();
180 v2[i] = seq->GetValue();
181 seq->Next();
182 }
183 vtkMath::Cross(v1, v2, v3);
184 vtkMath::Normalize(v1);
185 vtkMath::Normalize(v2);
186 vtkMath::Normalize(v3);
187
188 double a1_to_a12 = .1 + seq->GetValue();
189 seq->Next();
190 double a12_to_a2 = .1 + seq->GetValue();
191 seq->Next();
192
193 dist = seq->GetValue();
194 seq->Next();
195
196 double nearest[3];
197 for (unsigned i = 0; i < 3; i++)
198 {
199 nearest[i] = seq->GetValue();
200 seq->Next();
201 p[i] = nearest[i] + dist * v3[i];
202 a1[i] = nearest[i] - a1_to_a12 * v1[i];
203 a2[i] = nearest[i] + a12_to_a2 * v1[i];
204 }
205}
206
207double PointToLineSegment(double* p1, double* p2, double* p, double* pn, double& u)
208{

Callers 1

TestDistanceToLineFunction · 0.85

Calls 4

CrossFunction · 0.50
NormalizeFunction · 0.50
GetValueMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected