Next / Previous / Contents / Shipman's homepage

3.4. The Line class

An instance of this class represents a geometric line. Internally, the line is represented in the standard form ax + by + c = 0, but there are two other ways to create an instance.

Here is the general form of the constructor, where a, b, and c are the coefficients in that equation:

Line(a, b, c)

Instances of this class support these methods:


The argument other is also a Line instance. If the lines represented by self and other intersect, this method returns the point where they intersect as a Pt instance. This method will raise a ValueError exception if the lines are parallel or coincident.


Returns a string representing the line in standard form, as ax + by + c = 0, where the values of a, b, and c are filled in.

You may also create Line instances using these two static methods:

Line.twoPoint(p1, p2)

Returns a Line instance representing the line between two points p1 and p2 specified as Pt instances.

If the points coincide, this method will raise a ValueError exception.

Line.pointBearing(p, bears)

Returns a Line instance representing the line passing through point p, specified as a Pt instance, and having a slope specified by bears, an angle in radians.