[Math] How to know if a given point is inside a 2d circle’s segment

circlesgeometrytrigonometry

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

Best Answer

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.

Related Question