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

Method GeneralizedProjectPoint

Common/DataModel/vtkPlane.cxx:211–235  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Project a point x onto plane defined by origin and normal. The projected point is returned in xproj. NOTE : normal NOT required to have magnitude 1.

Source from the content-addressed store, hash-verified

209// projected point is returned in xproj. NOTE : normal NOT required to
210// have magnitude 1.
211void vtkPlane::GeneralizedProjectPoint(
212 const double x[3], const double origin[3], const double normal[3], double xproj[3])
213{
214 double t, xo[3], n2;
215
216 xo[0] = x[0] - origin[0];
217 xo[1] = x[1] - origin[1];
218 xo[2] = x[2] - origin[2];
219
220 t = vtkMath::Dot(normal, xo);
221 n2 = vtkMath::SquaredNorm(normal);
222
223 if (n2 != 0)
224 {
225 xproj[0] = x[0] - t * normal[0] / n2;
226 xproj[1] = x[1] - t * normal[1] / n2;
227 xproj[2] = x[2] - t * normal[2] / n2;
228 }
229 else
230 {
231 xproj[0] = x[0];
232 xproj[1] = x[1];
233 xproj[2] = x[2];
234 }
235}
236
237//------------------------------------------------------------------------------
238void vtkPlane::GeneralizedProjectPoint(const double x[3], double xproj[3])

Callers

nothing calls this directly

Calls 4

DotFunction · 0.70
SquaredNormFunction · 0.70
GetOriginMethod · 0.45
GetNormalMethod · 0.45

Tested by

no test coverage detected