Listing 6: Line intersection.
class Line def intersection(other) x = ((other.yintercept - self.yintercept)/(self.slope - other.slope)) y = ( self.yintercept + x*self.slope) if ( ((x >= other.getStart.x) && (other.getEnd.x >= x) ) || ((x >= other.getEnd.x) && (other.getStart.x >= x)) ) return Point.new(x, y) end end end