MCPcopy Create free account
hub / github.com/MITK/MITK / Project

Method Project

Modules/Core/include/mitkLine.h:205–219  ·  view source on GitHub ↗

\brief Project a point onto the line. * * If the direction vector has zero norm, the start point is returned. * * \param point The point to project. * \return The projected point on the line. */

Source from the content-addressed store, hash-verified

203 * \return The projected point on the line.
204 */
205 itk::Point<TCoordRep, NPointDimension> Project(const itk::Point<TCoordRep, NPointDimension> &point) const
206 {
207 if (m_Direction.GetNorm() == 0)
208 return this->m_Point;
209
210 itk::Vector<TCoordRep, NPointDimension> diff;
211 diff = point - this->m_Point;
212
213 itk::Vector<TCoordRep, NPointDimension> normalizedDirection = m_Direction;
214 normalizedDirection.Normalize();
215
216 normalizedDirection *= dot_product(diff.GetVnlVector(), normalizedDirection.GetVnlVector());
217
218 return this->m_Point + normalizedDirection;
219 }
220
221 /** \brief Test if a point is part of the line segment.
222 *

Callers 2

ProjectLandmarksMethod · 0.45

Calls 1

NormalizeMethod · 0.80

Tested by

no test coverage detected