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

| cite | improve this question | | | | |
  • $\begingroup$ How is the sector specified? How is the circle specified? $\endgroup$ – Gerry Myerson Aug 2 '12 at 3:10
  • $\begingroup$ @GerryMyerson Edited. $\endgroup$ – Casey Aug 2 '12 at 3:30
  • $\begingroup$ 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. $\endgroup$ – Gerry Myerson Aug 2 '12 at 3:50

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.

| cite | improve this answer | | | | |
  • $\begingroup$ Could you explain "Intersect the circle with the two lines and the circle forming the sector's boundary..."? $\endgroup$ – Casey Aug 3 '12 at 5:33
  • $\begingroup$ @Casey: I edited the answer to include some details on that. $\endgroup$ – joriki Aug 3 '12 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.