Given two segments that intersect, and a point $p$, how to know what of the two angles "points" towards $p$?

40 Views Asked by At

Here's a picture:

I'm given the extreme points of the segments $A$ and $B$, as well as the shortest angle between them. I need to know if that shortest angle is pointing "in" or "out" of $p$.

When I ask which of the angles points to $p$, I mean which of the two angles contains the segment that joins $p$ with the point of intersection of $A$ and $B$.

1

There are 1 best solutions below

0
On

Let $a=(x_a,y_a)$, $v=(x_v,y_v)$ be the endpoints of segment $A$, and $b$, $v$ be the endpoints of segment $B$. A "characteristic function" for line $av$ can be written as: $$ f_{av}(x,y)=(y-y_v)(x_a-x_v)-(x-x_v)(y_a-y_v). $$ This has the property of vanishing at a point if and only if that point belongs to line $av$. That entails that $f_{av}(m)\cdot f_{av}(n)>0$ if and only if points $m$ and $n$ belong to the same half-plane with respect to $av$.

In your case you must simply check that points $b$ and $p$ belong to the same half-plane with respect to $av$, that is $f_{av}(b)\cdot f_{av}(p)>0$, and that points $a$ and $p$ belong to the same half-plane with respect to $bv$, that is $f_{bv}(a)\cdot f_{bv}(p)>0$. Point $p$ belongs to the convex angle $\angle avb$ if and only if both conditions are satisfied.