Write code often encountered positional relationship between the judge and the vector point, do a simple recording, easy to use later.
First, the definition of the structure
Second, the definition judging function
def judgeDirection(startPoint, endPoint, P): tmp = (startPoint.y - endPoint.y)*P.x + (endPoint.x - startPoint.x)*P.y + startPoint.x*endPoint.y - endPoint.x*startPoint.y if tmp < 0: print("the point at the right of vector!") else: print("the point at the left of vertor")
Third, the test
-
A situation
-
Case 2