Module util :: Class LineSeg
[frames] | no frames]

Class LineSeg

Line segment in 2D space

Instance Methods
 
__init__(self, p1, p2)
Initialize with two points that are on the line.
 
closestPoint(self, p)
Return the point on the line that is closest to point p
 
distToPoint(self, p)
Shortest distance between point p and this line
 
intersection(self, other)
Return a Point where self intersects other.
 
__repr__(self)
Instance Variables
  p1
One point
  p2
Other point
  M
Vector from the stored point to the other point
Method Details

__init__(self, p1, p2)
(Constructor)

 

Initialize with two points that are on the line. Store one of the points and the vector between them.

intersection(self, other)

 

Return a Point where self intersects other. Returns False if there is no intersection.

Parameters:
  • other - a LineSeg