1
$\begingroup$

Is there a formula for determining if a sector intersects a circle (as well as determining if the circle/sector are inside each other)?

Sector definition: A center point $P(x,y)$, a starting angle in radians, an ending angle in radians, and a radius $r$ distance from the center point. The sector covers an area from the starting angle to the ending angle in a counter-clockwise direction where a starting angle of zero is right of the center point $r$ units away.

Circle definition: A center point $P(x, y)$ and a radius $r$.

  • 0
    Presumably, the center point are given as $x,y$-values in a Cartesian plane, and the angles are measured in some specified direction relative to some specified direction. You still need to add these specifications for your problem to be well-defined.2012-08-02

1 Answers 1

1

Intersect the circle with the two lines and the circle forming the sector's boundary; in each case, if there are intersections, check whether they lie within the part (line segment or arc) forming the boundary. If you don't find intersections, the sector and circle are either disjoint, or one is contained in the other; you can check for the latter case by determining whether the centre of either circle is inside the other object.

[Edit in response to the comment:]

The sector is bounded by two line segments and a circular arc, which are parts of two lines and a circle, respectively. To intersect a line given by $\vec n\cdot\vec x=c$ (with $\vec n$ a unit normal vector) and a circle given by $(\vec x-\vec x_0)^2=r^2$, find the (signed) distance $d=\vec n\cdot\vec x_0-c$ of the circle's origin from the line. If $d\gt r$ there are nor intersections; if $d\le r$, the intersections are at

$\vec x_0-d\vec n\pm\sqrt{r^2-d^2}\,\vec y\;,$

where $y$ is a unit vector with $\vec n\cdot\vec y=0$, i.e. in either direction along the line.

To intersect two circles given by $(\vec x-\vec x_1)^2=r_1^2$ and $(\vec x-\vec x_2)^2=r_2^2$, subtract the two equations to obtain

$2(\vec x_2-\vec x_1)\cdot\vec x=r_1^2-r_2^2-\vec x_1^2+\vec x_2^2\;,$

which is an equation for a line perpendicular to the line connecting the two centres, which you can intersect with one of the circles as described above to find the intersections of the circles.

  • 0
    @Casey: I edited the answer to include some details on that.2012-08-03