4
$\begingroup$

This is for a real life situation not a theoretical one. I'm trying to check if a point exist in a Segment of a 2d circle. In other words, I need to know if a given point P(x,y) is anywhere inside the blue part of the circle (see image below).

Given The radius, the center $(x, y)$, point $A(x,y)$, point $B(x,y)$. The point $P(x,y)$ is also given and I need to know if it's inside or outside the Circle's segment.

What I don't know The Arc Length and the Center Angle of the Sector.

enter image description here

$\endgroup$
2
  • $\begingroup$ Do you know how to use linear algebra to project a point onto a line? $\endgroup$
    – Théophile
    Dec 15, 2015 at 17:08
  • $\begingroup$ @Théophile, I do not. $\endgroup$ Dec 15, 2015 at 17:09

3 Answers 3

1
$\begingroup$

Given a circle of radius $r$ centered at $C$ and an oriented arc $AB$ of the circle, a query point $P$ is in the circular segment detemined by the chord $AB$ iff all these conditions hold:

  • $P$ is inside the circle: $d(O,P)\le r$

  • $P$ is to the left of $OA$: $OA \times OP \ge 0$

  • $P$ is to the right of $AB$: $AB \times AP \le 0$

  • $P$ is to the right of $OB$: $OB \times OP \le 0$

Here $\times$ is the two-dimensional cross product.

$\endgroup$
0
$\begingroup$

You can figure out if it is in the segment by finding out what angles bound the box, what the radius of the circle is, and the equation of the line between A and B. If the angle from $O(x,y)$ to $P(x,y)$ is between angle OA and OB, and the radius is between $y_{AB}$ and R, then the point is in the segment.

$\angle OA = \tan^{-1}\big(\frac{x_A-x_O}{y_A-y_O}\big)$

$\angle OB = \tan^{-1}\big(\frac{x_B-x_O}{y_B-y_O}\big)$

$\angle OP = \tan^{-1}\big(\frac{x_P-x_O}{y_P-y_O}\big)$

$R = \sqrt{(x_A-x_O)^2+(y_A-y_O)^2}$

and the equation of the line AB is:

$y_{AB} = \frac{y_B-y_A}{x_B-x_A}x+y_A$

$\endgroup$
0
$\begingroup$

let the point $C$ is half of the $[A,B]$. A point $P$ lies in the segment if $$ |OA| < |OP| < |OC|.$$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .