Created
March 22, 2011 00:56
-
-
Save FloooD/880563 to your computer and use it in GitHub Desktop.
returns 1 if a line segment intersects a circle. returns 0 otherwise. (note: uses polar coordinates.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int line_seg_circ_polar(float er, float etheta, float cr, float ctheta, float cradius) | |
{ | |
if (cradius >= cr) return 1; | |
if (fabsf(etheta - ctheta) > asinf(cradius / cr)) return 0; | |
if (er * er < cr * cr - cradius * cradius && er * er + cr * cr - 2 * er * cr * cosf(etheta - ctheta) > cradius * cradius) return 0; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment