0
$\begingroup$

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$.

  • 0
    Your question is meaningless in 3D, it makes sense only in a plane. Fortunately, two intersecting lines do determine a plane, so you're safe.2017-01-04
  • 0
    @AlexM. My bad! it's a typo, I meant 2D.2017-01-04
  • 0
    And how do you wish to determine this? Are you using a computer/programming language? Does it have an "atan2" function? Do you know what vectors are?2017-01-04

1 Answers 1

0

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.