Descibes a line. More...
#include <mitkLine.h>
Public Member Functions | |
Line () | |
Line (const itk::Point< TCoordRep, NPointDimension > &point, const itk::Vector< TCoordRep, NPointDimension > &direction) | |
Define line by point and direction. | |
const itk::Point< TCoordRep, NPointDimension > & | GetPoint () const |
Get start point of the line. | |
itk::Point< TCoordRep, NPointDimension > & | GetPoint () |
Get start point of the line. | |
const itk::Point< TCoordRep, NPointDimension > | GetPoint (TCoordRep t) const |
Get point on the line with parameter t. | |
void | SetPoint (const itk::Point< TCoordRep, NPointDimension > &point1) |
Set/change start point of the line. | |
const itk::Vector< TCoordRep, NPointDimension > & | GetDirection () const |
Get the direction vector of the line. | |
itk::Vector< TCoordRep, NPointDimension > & | GetDirection () |
Get the direction vector of the line. | |
void | SetDirection (const itk::Vector< TCoordRep, NPointDimension > &direction) |
Set the direction vector of the line. | |
void | Set (const itk::Point< TCoordRep, NPointDimension > &point, const itk::Vector< TCoordRep, NPointDimension > &direction) |
Define line by point and direction. | |
void | SetPoints (const itk::Point< TCoordRep, NPointDimension > &point1, const itk::Point< TCoordRep, NPointDimension > &point2) |
Define line by two points. | |
void | SetPoint1 (const itk::Point< TCoordRep, NPointDimension > &point1) |
Set/change start point of the line. | |
const itk::Point< TCoordRep, NPointDimension > & | GetPoint1 () const |
Get start point of the line. | |
void | SetPoint2 (const itk::Point< TCoordRep, NPointDimension > &point2) |
Set/change end point of the line. | |
itk::Point< TCoordRep, NPointDimension > | GetPoint2 () const |
Get end point of the line. | |
void | Transform (itk::Transform< TCoordRep, NPointDimension, NPointDimension > &transform) |
Transform the line with a Transform. | |
void | Transform (const itk::Matrix< TCoordRep, NPointDimension, NPointDimension > &matrix) |
Transform the line with a matrix. | |
double | Distance (const Line< TCoordRep, NPointDimension > &line) const |
Distance between two lines. | |
double | Distance (const itk::Point< TCoordRep, NPointDimension > &point) const |
Distance of a point from the line. | |
itk::Point< TCoordRep, NPointDimension > | Project (const itk::Point< TCoordRep, NPointDimension > &point) const |
Project a point on the line. | |
bool | IsPartOfStraightLine (const itk::Point< TCoordRep, NPointDimension > &point) const |
Test if a point is part of the line. | |
bool | IsPartOfLine (const itk::Point< TCoordRep, NPointDimension > &point) const |
Test if a point is part of the line (line having infinite length) | |
bool | IsParallel (const Line< TCoordRep, NPointDimension > &line) const |
Test if a lines is parallel to this line. | |
bool | IsPartOfLine (const Line< TCoordRep, NPointDimension > &line) const |
Test if a line is part of the line (line having infinite length) | |
bool | operator== (const Line< TCoordRep, NPointDimension > &line) const |
Test if the two lines are identical. | |
const Line< TCoordRep, NPointDimension > & | operator= (const Line< TCoordRep, NPointDimension > &line) |
Set the line by another line. | |
bool | operator!= (const Line< TCoordRep, NPointDimension > &line) const |
Test if two lines are not identical. | |
Static Public Member Functions | |
static int | RectangleLineIntersection (TCoordRep x1, TCoordRep y1, TCoordRep x2, TCoordRep y2, itk::Point< TCoordRep, 2 > p, itk::Vector< TCoordRep, 2 > d, itk::Point< TCoordRep, 2 > &s1, itk::Point< TCoordRep, 2 > &s2) |
Calculates the intersection points of a straight line in 2D with a rectangle. | |
static int | BoxLineIntersection (TCoordRep x1, TCoordRep y1, TCoordRep z1, TCoordRep x2, TCoordRep y2, TCoordRep z2, itk::Point< TCoordRep, 3 > p, itk::Vector< TCoordRep, 3 > d, itk::Point< TCoordRep, 3 > &s1, itk::Point< TCoordRep, 3 > &s2) |
Calculates the intersection points of a straight line in 3D with a box. | |
Protected Attributes | |
itk::Point< TCoordRep, NPointDimension > | m_Point |
itk::Vector< TCoordRep, NPointDimension > | m_Direction |
Descibes a line.
Definition at line 34 of file mitkLine.h.
mitk::Line< TCoordRep, NPointDimension >::Line | ( | ) | [inline] |
Definition at line 37 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ m_Point.Fill(0); m_Direction.Fill(0); };
mitk::Line< TCoordRep, NPointDimension >::Line | ( | const itk::Point< TCoordRep, NPointDimension > & | point, |
const itk::Vector< TCoordRep, NPointDimension > & | direction | ||
) | [inline] |
Define line by point and direction.
Length of direction defines the the length of the line
Definition at line 47 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ this->m_Point = point; this->m_Direction = direction; }
static int mitk::Line< TCoordRep, NPointDimension >::BoxLineIntersection | ( | TCoordRep | x1, |
TCoordRep | y1, | ||
TCoordRep | z1, | ||
TCoordRep | x2, | ||
TCoordRep | y2, | ||
TCoordRep | z2, | ||
itk::Point< TCoordRep, 3 > | p, | ||
itk::Vector< TCoordRep, 3 > | d, | ||
itk::Point< TCoordRep, 3 > & | s1, | ||
itk::Point< TCoordRep, 3 > & | s2 | ||
) | [inline, static] |
Calculates the intersection points of a straight line in 3D with a box.
x1,y1,z1 | first corner of the box |
x2,y2,z2 | second corner of the box |
p,d | straight line: p point on it, d direction of line |
s1 | first intersection point (valid only if s_num>0) |
s2 | second intersection point (valid only if s_num==2) |
Definition at line 373 of file mitkLine.h.
Referenced by mitk::Geometry2DDataMapper2D::Paint().
{ int num = 0; ScalarType box[6]; box[0] = x1; box[1] = x2; box[2] = y1; box[3] = y2; box[4] = z1; box[5] = z2; itk::Point< TCoordRep, 3 > point; int i, j; for ( i = 0; i < 6; ++i ) { j = i / 2; if ( fabs( d[j] ) > eps ) { ScalarType lambda = (box[i] - p[j]) / d[j]; point = p + d * lambda; int k = (j + 1) % 3; int l = (j + 2) % 3; if ( (point[k] >= box[k*2]) && (point[k] <= box[k*2+1]) && (point[l] >= box[l*2]) && (point[l] <= box[l*2+1]) ) { if ( num == 0 ) { s1 = point; } else { s2 = point; } ++num; } } } return num; }
double mitk::Line< TCoordRep, NPointDimension >::Distance | ( | const itk::Point< TCoordRep, NPointDimension > & | point ) | const [inline] |
Distance of a point from the line.
Definition at line 184 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::Project().
{ itk::Vector<TCoordRep,NPointDimension> diff; diff = Project(point)-point; return diff.GetNorm(); }
double mitk::Line< TCoordRep, NPointDimension >::Distance | ( | const Line< TCoordRep, NPointDimension > & | line ) | const |
Distance between two lines.
Referenced by mitk::Line< TCoordRep, NPointDimension >::IsPartOfLine(), mitk::Line< TCoordRep, NPointDimension >::IsPartOfStraightLine(), and mitk::Mesh::SearchLine().
const itk::Vector<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::GetDirection | ( | ) | const [inline] |
Get the direction vector of the line.
Definition at line 89 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction.
Referenced by mitk::PlaneGeometry::IntersectionPoint(), mitk::Line< TCoordRep, NPointDimension >::IsParallel(), mitk::Line< TCoordRep, NPointDimension >::operator=(), and mitk::Geometry2DDataMapper2D::Paint().
{ return m_Direction; }
itk::Vector<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::GetDirection | ( | ) | [inline] |
Get the direction vector of the line.
Definition at line 96 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction.
{ return m_Direction; }
const itk::Point<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::GetPoint | ( | ) | const [inline] |
Get start point of the line.
Definition at line 55 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::PlaneGeometry::IsOnPlane(), mitk::Line< TCoordRep, NPointDimension >::IsPartOfLine(), mitk::Line< TCoordRep, NPointDimension >::operator=(), mitk::MeshMapper2D::Paint(), and mitk::Geometry2DDataMapper2D::Paint().
{ return m_Point; }
itk::Point<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::GetPoint | ( | ) | [inline] |
Get start point of the line.
Definition at line 62 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ return m_Point; }
const itk::Point<TCoordRep,NPointDimension> mitk::Line< TCoordRep, NPointDimension >::GetPoint | ( | TCoordRep | t ) | const [inline] |
Get point on the line with parameter t.
Definition at line 71 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, mitk::Line< TCoordRep, NPointDimension >::m_Point, and QuadProgPP::t().
{ return m_Point+m_Direction*t; }
const itk::Point<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::GetPoint1 | ( | ) | const [inline] |
Get start point of the line.
Definition at line 140 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::Line< TCoordRep, NPointDimension >::operator==(), and mitk::Geometry2DDataMapper2D::Paint().
{ return m_Point; }
itk::Point<TCoordRep,NPointDimension> mitk::Line< TCoordRep, NPointDimension >::GetPoint2 | ( | ) | const [inline] |
Get end point of the line.
Definition at line 154 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::PlaneGeometry::IsOnPlane(), and mitk::Line< TCoordRep, NPointDimension >::operator==().
{ itk::Point<TCoordRep,NPointDimension> point2; point2 = m_Point+m_Direction; return point2; }
bool mitk::Line< TCoordRep, NPointDimension >::IsParallel | ( | const Line< TCoordRep, NPointDimension > & | line ) | const [inline] |
Test if a lines is parallel to this line.
Definition at line 242 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::GetDirection(), and mitk::Line< TCoordRep, NPointDimension >::m_Direction.
Referenced by mitk::Line< TCoordRep, NPointDimension >::IsPartOfLine().
{ vnl_vector<TCoordRep> normal; normal = vnl_cross_3d( m_Direction.Get_vnl_vector(), line.GetDirection().Get_vnl_vector() ); if ( normal.squared_magnitude() < eps ) return true; return false; }
bool mitk::Line< TCoordRep, NPointDimension >::IsPartOfLine | ( | const itk::Point< TCoordRep, NPointDimension > & | point ) | const [inline] |
Test if a point is part of the line (line having infinite length)
Definition at line 232 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::Distance().
{ if ( Distance( point ) < eps ) return true; return false; }
bool mitk::Line< TCoordRep, NPointDimension >::IsPartOfLine | ( | const Line< TCoordRep, NPointDimension > & | line ) | const [inline] |
Test if a line is part of the line (line having infinite length)
Definition at line 256 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::Distance(), mitk::Line< TCoordRep, NPointDimension >::GetPoint(), and mitk::Line< TCoordRep, NPointDimension >::IsParallel().
{ return ( Distance( line.GetPoint() ) < 0 ) && ( IsParallel( line ) ); }
bool mitk::Line< TCoordRep, NPointDimension >::IsPartOfStraightLine | ( | const itk::Point< TCoordRep, NPointDimension > & | point ) | const [inline] |
Test if a point is part of the line.
Length of the direction vector defines the length of the line
Definition at line 213 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::Distance(), mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ if( Distance( point ) > eps ) return false; itk::Vector<TCoordRep,NPointDimension> diff; diff = point - this->m_Point; if( diff*m_Direction < 0 ) return false; if( diff.GetSquaredNorm() <= m_Direction.GetSquaredNorm() ) return true; return false; }
bool mitk::Line< TCoordRep, NPointDimension >::operator!= | ( | const Line< TCoordRep, NPointDimension > & | line ) | const [inline] |
Test if two lines are not identical.
Definition at line 291 of file mitkLine.h.
{
return !((*this)==line);
}
const Line<TCoordRep,NPointDimension>& mitk::Line< TCoordRep, NPointDimension >::operator= | ( | const Line< TCoordRep, NPointDimension > & | line ) | [inline] |
Set the line by another line.
Definition at line 280 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::GetDirection(), mitk::Line< TCoordRep, NPointDimension >::GetPoint(), mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ m_Point = line.GetPoint(); m_Direction = line.GetDirection(); return *this; }
bool mitk::Line< TCoordRep, NPointDimension >::operator== | ( | const Line< TCoordRep, NPointDimension > & | line ) | const [inline] |
Test if the two lines are identical.
Start point and direction and length of direction vector must be equal for identical lines.
Definition at line 266 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::GetPoint1(), and mitk::Line< TCoordRep, NPointDimension >::GetPoint2().
itk::Point<TCoordRep,NPointDimension> mitk::Line< TCoordRep, NPointDimension >::Project | ( | const itk::Point< TCoordRep, NPointDimension > & | point ) | const [inline] |
Project a point on the line.
Definition at line 193 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::Line< TCoordRep, NPointDimension >::Distance(), mitk::SlicesRotator::ExecuteAction(), and mitk::SlicesRotator::RotateToPoint().
{ if(m_Direction.GetNorm()==0) return this->m_Point; itk::Vector<TCoordRep,NPointDimension> diff; diff = point-this->m_Point; itk::Vector<TCoordRep,NPointDimension> normalizedDirection = m_Direction; normalizedDirection.Normalize(); normalizedDirection *= dot_product(diff.Get_vnl_vector(), normalizedDirection.Get_vnl_vector()); return this->m_Point + normalizedDirection; }
static int mitk::Line< TCoordRep, NPointDimension >::RectangleLineIntersection | ( | TCoordRep | x1, |
TCoordRep | y1, | ||
TCoordRep | x2, | ||
TCoordRep | y2, | ||
itk::Point< TCoordRep, 2 > | p, | ||
itk::Vector< TCoordRep, 2 > | d, | ||
itk::Point< TCoordRep, 2 > & | s1, | ||
itk::Point< TCoordRep, 2 > & | s2 | ||
) | [inline, static] |
Calculates the intersection points of a straight line in 2D with a rectangle.
x1,y1,x2,y2 | rectangle |
p,d | straight line: p point on it, d direction of line |
s1 | first intersection point (valid only if s_num>0) |
s2 | second intersection point (valid only if s_num==2) |
Definition at line 305 of file mitkLine.h.
References QuadProgPP::t().
{ int s_num; TCoordRep t; s_num=0; /*test if intersecting with the horizontal axis*/ if(fabs(d[0])>eps) { t=(x1-p[0])/d[0]; itk::Point<TCoordRep,2> l=p+d*t; if((l[1]>=y1) && (l[1]<y2)) { // yes, intersection point within the bounds of the border-line if(s_num) s2=l; else s1=l; ++s_num; } } if(fabs(d[0])>eps) { t=(x2-p[0])/d[0]; itk::Point<TCoordRep,2> l=p+d*t; if((l[1]>=y1) && (l[1]<y2)) { // yes, intersection point within the bounds of the border-line if(s_num) s2=l; else s1=l; ++s_num; } } /*test if intersecting with the vertical axis*/ if(fabs(d[1])>eps) { t=(y1-p[1])/d[1]; itk::Point<TCoordRep,2> l=p+d*t; if((l[0]>=x1) && (l[0]<x2)) { // yes, intersection point within the bounds of the border-line if(s_num) s2=l; else s1=l; ++s_num; } } if(fabs(d[1])>eps) { t=(y2-p[1])/d[1]; itk::Point<TCoordRep,2> l=p+d*t; if((l[0]>=x1) && (l[0]<x2)) { // yes, intersection point within the bounds of the border-line if(s_num) s2=l; else s1=l; ++s_num; } } return s_num; }
void mitk::Line< TCoordRep, NPointDimension >::Set | ( | const itk::Point< TCoordRep, NPointDimension > & | point, |
const itk::Vector< TCoordRep, NPointDimension > & | direction | ||
) | [inline] |
Define line by point and direction.
Length of direction defines the the length of the line
Definition at line 112 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ this->m_Point = point; this->m_Direction = direction; }
void mitk::Line< TCoordRep, NPointDimension >::SetDirection | ( | const itk::Vector< TCoordRep, NPointDimension > & | direction ) | [inline] |
Set the direction vector of the line.
Definition at line 103 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction.
{ m_Direction = direction; }
void mitk::Line< TCoordRep, NPointDimension >::SetPoint | ( | const itk::Point< TCoordRep, NPointDimension > & | point1 ) | [inline] |
Set/change start point of the line.
Definition at line 78 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ itk::Vector<TCoordRep,NPointDimension> point2; point2 = m_Point + m_Direction; m_Point = point1; m_Direction = point2 - point1; }
void mitk::Line< TCoordRep, NPointDimension >::SetPoint1 | ( | const itk::Point< TCoordRep, NPointDimension > & | point1 ) | [inline] |
Set/change start point of the line.
Definition at line 129 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ itk::Vector<TCoordRep,NPointDimension> point2; point2 = m_Point + m_Direction; m_Point = point1; m_Direction = point2 - point1; }
void mitk::Line< TCoordRep, NPointDimension >::SetPoint2 | ( | const itk::Point< TCoordRep, NPointDimension > & | point2 ) | [inline] |
Set/change end point of the line.
Definition at line 147 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
{ m_Direction = point2 - m_Point; }
void mitk::Line< TCoordRep, NPointDimension >::SetPoints | ( | const itk::Point< TCoordRep, NPointDimension > & | point1, |
const itk::Point< TCoordRep, NPointDimension > & | point2 | ||
) | [inline] |
Define line by two points.
Definition at line 120 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::PlaneCutFilter::_computeIntersection(), mitk::MeshMapper2D::Paint(), mitk::Geometry2DDataMapper2D::Paint(), and mitk::Mesh::SearchLine().
{ this->m_Point = point1; //this->m_Direction.sub( point2, point1 ); m_Direction = point2 - point1; }
void mitk::Line< TCoordRep, NPointDimension >::Transform | ( | itk::Transform< TCoordRep, NPointDimension, NPointDimension > & | transform ) | [inline] |
Transform the line with a Transform.
Definition at line 163 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction, and mitk::Line< TCoordRep, NPointDimension >::m_Point.
Referenced by mitk::Geometry2DDataMapper2D::Paint().
{ m_Direction = transform.TransformVector(m_Direction); m_Point = transform.TransformPoint(m_Point); }
void mitk::Line< TCoordRep, NPointDimension >::Transform | ( | const itk::Matrix< TCoordRep, NPointDimension, NPointDimension > & | matrix ) | [inline] |
Transform the line with a matrix.
Only the direction will be changed, not the start point.
Definition at line 173 of file mitkLine.h.
References mitk::Line< TCoordRep, NPointDimension >::m_Direction.
{ m_Direction = matrix*m_Direction; }
itk::Vector<TCoordRep,NPointDimension> mitk::Line< TCoordRep, NPointDimension >::m_Direction [protected] |
Definition at line 422 of file mitkLine.h.
Referenced by mitk::Line< TCoordRep, NPointDimension >::GetDirection(), mitk::Line< TCoordRep, NPointDimension >::GetPoint(), mitk::Line< TCoordRep, NPointDimension >::GetPoint2(), mitk::Line< TCoordRep, NPointDimension >::IsParallel(), mitk::Line< TCoordRep, NPointDimension >::IsPartOfStraightLine(), mitk::Line< TCoordRep, NPointDimension >::Line(), mitk::Line< TCoordRep, NPointDimension >::operator=(), mitk::Line< TCoordRep, NPointDimension >::Project(), mitk::Line< TCoordRep, NPointDimension >::Set(), mitk::Line< TCoordRep, NPointDimension >::SetDirection(), mitk::Line< TCoordRep, NPointDimension >::SetPoint(), mitk::Line< TCoordRep, NPointDimension >::SetPoint1(), mitk::Line< TCoordRep, NPointDimension >::SetPoint2(), mitk::Line< TCoordRep, NPointDimension >::SetPoints(), and mitk::Line< TCoordRep, NPointDimension >::Transform().
itk::Point<TCoordRep,NPointDimension> mitk::Line< TCoordRep, NPointDimension >::m_Point [protected] |
Definition at line 421 of file mitkLine.h.
Referenced by mitk::Line< TCoordRep, NPointDimension >::GetPoint(), mitk::Line< TCoordRep, NPointDimension >::GetPoint1(), mitk::Line< TCoordRep, NPointDimension >::GetPoint2(), mitk::Line< TCoordRep, NPointDimension >::IsPartOfStraightLine(), mitk::Line< TCoordRep, NPointDimension >::Line(), mitk::Line< TCoordRep, NPointDimension >::operator=(), mitk::Line< TCoordRep, NPointDimension >::Project(), mitk::Line< TCoordRep, NPointDimension >::Set(), mitk::Line< TCoordRep, NPointDimension >::SetPoint(), mitk::Line< TCoordRep, NPointDimension >::SetPoint1(), mitk::Line< TCoordRep, NPointDimension >::SetPoint2(), mitk::Line< TCoordRep, NPointDimension >::SetPoints(), and mitk::Line< TCoordRep, NPointDimension >::Transform().