# Author : Steven Miller # Course Number : 22C:016 SCA # Student ID : 4784653 def slope(p1, p2) : ''' Returns the slope of points p1 and p2 ''' slope = None # assume points are on a vertical line if float(p2[0])-float(p1[0]) != 0.0 : # if not on a vertical line # compute their slope slope = (float(p2[1]) - float(p1[1])) / (float(p2[0]) - float(p1[0])) return slope def areCollinear(p1, p2, p3) : ''' Returns true if points p1, p2, and p3 are collinear''' # p1, p2, and p3 are collinear if slope(p1,p2) == slope(p2,p3) return slope(p1,p2) == slope(p2,p3)