Next / Previous / Contents / Shipman's homepage

14. class Line: Equation of a line

Here is the formal interface to the class.

homcoord.py
# - - - - -   c l a s s   L i n e

class Line(object):
    '''Represents a geometric line.

      Exports:
        Line(a, b, c):
          [ a, b, and c are floats ->
              return a Line instance representing ax+by+c=0 ]
        .a, .b, .c:  [ as passed to constructor, read-only ]
        .__str__(self):   [ return self as a string ]
        .intersect(other):
          [ other is a Line instance ->
              if self and other intersect ->
                return the intersection as a Pt
              else -> raise ValueError ]
        Line.twoPoint(p1, p2):       # Static method
          [ p1 and p2 are Pt instances ->
              if p1 and p2 are distinct ->
                return a Line instance representing the line that
                intersects p1 and p2
              else -> raise ValueError ]
        Line.pointBearing(p, bears):   # Static method
          [ (p is a Pt instance) and
            (bears is a Cartesian bearing in radians) ->
              return the line through p at bearing (bears) ]
    '''