Reputation: 1894
My Question is very similar to this one: How to tell whether a point is to the right or left side of a line.
They got a line defined between two points A,B and a third point Z that should be tested.
I got a line defined by a point P and angle a and the third point Z that should be tested. Obviously i could compute the third point from the angle and P and use their solution, but i hope there is a better/faster way.
Z and Z' should register as "above", Z'' should register as "below" the line.
Background: I'm programming C++ with OpenCV and currently am trying to make sense of the relation between detected rotated Rectangles.
Upvotes: 1
Views: 523
Reputation: 80177
You have two vectors - direction vector D=(sin(a),cos(a)) and PZ. If their cross product is positive, then Z lies in left semiplane, otherwise - in right semiplane. What semiplane is considered as 'above' - depends on cos(a) sign.
Result = cos(a) * (sin(a) * PZ.Y - cos(a) * PZ.X) > 0
Upvotes: 2