17 #include <itkMatrix.h>
18 #include <itkTransform.h>
19 #include <vnl/vnl_cross.h>
20 #include <vnl/vnl_vector.h>
27 template <
class TCoordRep,
unsigned int NPo
intDimension = 3>
41 Line(
const itk::Point<TCoordRep, NPointDimension> &point,
const itk::Vector<TCoordRep, NPointDimension> &direction)
49 const itk::Point<TCoordRep, NPointDimension> &
GetPoint()
const {
return m_Point; }
60 void SetPoint(
const itk::Point<TCoordRep, NPointDimension> &point1)
62 itk::Point<TCoordRep, NPointDimension> point2;
65 m_Direction = point2.GetVectorFromOrigin() - point1.GetVectorFromOrigin();
81 void Set(
const itk::Point<TCoordRep, NPointDimension> &point,
82 const itk::Vector<TCoordRep, NPointDimension> &direction)
90 void SetPoints(
const itk::Point<TCoordRep, NPointDimension> &point1,
91 const itk::Point<TCoordRep, NPointDimension> &point2)
100 void SetPoint1(
const itk::Point<TCoordRep, NPointDimension> &point1)
102 itk::Vector<TCoordRep, NPointDimension> point2;
106 m_Direction = point2 - point1.GetVectorFromOrigin();
117 itk::Point<TCoordRep, NPointDimension>
GetPoint2()
const
119 itk::Point<TCoordRep, NPointDimension> point2;
126 void Transform(itk::Transform<TCoordRep, NPointDimension, NPointDimension> &transform)
136 void Transform(
const itk::Matrix<TCoordRep, NPointDimension, NPointDimension> &matrix)
143 double Distance(
const itk::Point<TCoordRep, NPointDimension> &point)
const
145 itk::Vector<TCoordRep, NPointDimension> diff;
147 return diff.GetNorm();
152 itk::Point<TCoordRep, NPointDimension>
Project(
const itk::Point<TCoordRep, NPointDimension> &point)
const
157 itk::Vector<TCoordRep, NPointDimension> diff;
160 itk::Vector<TCoordRep, NPointDimension> normalizedDirection =
m_Direction;
161 normalizedDirection.Normalize();
163 normalizedDirection *= dot_product(diff.GetVnlVector(), normalizedDirection.GetVnlVector());
165 return this->m_Point + normalizedDirection;
177 itk::Vector<TCoordRep, NPointDimension> diff;
183 if (diff.GetSquaredNorm() <=
m_Direction.GetSquaredNorm())
191 bool IsPartOfLine(
const itk::Point<TCoordRep, NPointDimension> &point)
const
203 vnl_vector<TCoordRep> normal;
207 if (normal.squared_magnitude() <
eps)
227 itk::Vector<TCoordRep, NPointDimension> diff;
229 if (diff.GetSquaredNorm() >
eps)
232 if (diff.GetSquaredNorm() >
eps)
264 itk::Point<TCoordRep, 2> p,
265 itk::Vector<TCoordRep, 2> d,
266 itk::Point<TCoordRep, 2> &s1,
267 itk::Point<TCoordRep, 2> &s2)
274 if (fabs(d[0]) >
eps)
276 t = (x1 - p[0]) / d[0];
277 itk::Point<TCoordRep, 2> l = p + d * t;
278 if ((l[1] >= y1) && (l[1] < y2))
288 if (fabs(d[0]) >
eps)
290 t = (x2 - p[0]) / d[0];
291 itk::Point<TCoordRep, 2> l = p + d * t;
293 if ((l[1] >= y1) && (l[1] < y2))
304 if (fabs(d[1]) >
eps)
306 t = (y1 - p[1]) / d[1];
307 itk::Point<TCoordRep, 2> l = p + d * t;
309 if ((l[0] >= x1) && (l[0] < x2))
319 if (fabs(d[1]) >
eps)
321 t = (y2 - p[1]) / d[1];
322 itk::Point<TCoordRep, 2> l = p + d * t;
323 if ((l[0] >= x1) && (l[0] < x2))
352 itk::Point<TCoordRep, 3> p,
353 itk::Vector<TCoordRep, 3> d,
354 itk::Point<TCoordRep, 3> &s1,
355 itk::Point<TCoordRep, 3> &s2)
367 itk::Point<TCoordRep, 3> point;
370 for (i = 0; i < 6; ++i)
373 if (fabs(d[j]) >
eps)
377 point = p + d * lambda;
382 if ((((point[k] >= box[k * 2]) && (point[k] <= box[k * 2 + 1])) ||
383 ((point[k] <= box[k * 2]) && (point[k] >= box[k * 2 + 1]))) &&
384 (((point[l] >= box[l * 2]) && (point[l] <= box[l * 2 + 1])) ||
385 ((point[l] <= box[l * 2]) && (point[l] >= box[l * 2 + 1])))
405 itk::Point<TCoordRep, NPointDimension>
m_Point;