Hi Abu, > Question: how to determine whether point C is to the left or to the > right of the line AB?
When the line given by A(Xa,Ya) and B(Xb, Yb), the area of the A-B-C triangle can be calculated with the value of next determinant / 2 | Xa, Ya, 1 | | Xb, Yb, 1 | | Xc, Yc, 1 | / 2 So: Area = ( Xa(Yb-Yc) - Xb(Ya-Yc) + Xc(Ya-Yb) ) / 2 Area > 0 | the points are clockwise (C is on the left) Area < 0 | the points are counterclockwise (C is on the right) Area = 0 | the points are on the same line It can be written in a python function ########### def TriArea(a, b, c): #Area = (Xa(Yb-Yc) - Xb(Ya-Yc) + Xc(Ya-Yb)) /2 return ( a[0] * (b[1]-c[1]) - b[0] * (a[1]-c[1]) + c[0] * (a[1]-b[1]) )/2 ########### # to test it. print TriArea((0,0), (10,0), (2,2)) print TriArea((0,0), (10,0), (2,-2)) print TriArea((0,0), (10,0), (2,0)) ########### The biggest advantage of this calculation is that, it never goes to zero division exception. Best regards, Janos _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor