CollinearityTest - #Programmer Zhaoyang Dai#Section...

Info icon This preview shows pages 1–2. Sign up to view the full content.

#Programmer: Zhaoyang Dai #Section: 22C:016:A06 #ID: 00719596 def collinearityTest(pointList): n=len(pointList) a=0 #a indicates the first position in pointList b=1 #b indicates the first position in pointList c=2 #c indicates the first position in pointList #loop to generate all possible collinear points while a<b<c<=n-1: #loop to generate all possible collinear points when a is unchanged while b<c<=n-1: #loop to generate all possible collinear points when b is unchanged while c<=n-1: #test if points are collinear if areCollinear(pointList[a],pointList[b],pointList[c]): return[pointList[a],pointList[b],pointList[c]] c=c+1 #change c b=b+1 #change b c=b+1 #to ensure c is greater than b a=a+1 #change a b=a+1 #to ensure b is greater than a c=b+1 #to ensure c is greater than b
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #if there is no output, return an empty list if not areCollinear(pointList[a],pointList[b],pointList[c]): return def areCollinear(p1, p2, p3): a=float(p1[0]) #Changes the number of x,y coordinate to float, b=float(p2[0]) #since there is a case that when an integer divided c=float(p3[0]) #by another integer, the output would also be d=float(p1[1]) #approximately equal to an integer,it makes the e=float(p2[1]) #output inaccurate. f=float(p3[1]) if d==e or d==f or e==f: #prvent the denominator becomes zero if a==b==c or d==e==f: #these are lines which are perpendicular to x,y axis return True else: return False else: if (a-b)/(d-e)==(b-c)/(e-f): #if the slope are the same, 3 points are collinear return True else: return False...
View Full Document

  • Fall '13
  • MichaelColbert
  • Division, Zhaoyang Dai, possible collinear points

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern