Jump to content

Detect sectors of a circle


GaryS
 Share

Recommended Posts

So, circles are confounding me today... About twenty years ago I did GCSE maths and remember wondering when or why I would ever need to know any of this stuff about circles and angles and the like.
Now. Now is when I need to know all that stuff.

So I've been all over the interwebz and have learned lots about circles, but while there are myriad explainations of how to work out the length of an arc, the angle and area of a sector... and use both radians and degrees to calculate same; I can find nothing that will tell me which sector a given value (theta, radian, degree, whatever) is in.

If I've divided my circle into 12 segments, can I pass a value and know that it belongs in sector 3, for instance?



 

Link to comment
Share on other sites

I've made the changes directly to the last example you shared. You can find the code to detect a segment in the create tab.
http://phaser.io/sandbox/zDpiEpoY

The steps are:
Ensure the rotation value you have exists in a 0<->X range, and not a -Y<->Y range.
Divide that number by the size of each segment in rads or degrees, and then round the number down to get the segment index.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...