GaryS Posted October 10, 2016 Share Posted October 10, 2016 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 More sharing options...
lumoludo Posted October 10, 2016 Share Posted October 10, 2016 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. samme 1 Link to comment Share on other sites More sharing options...
GaryS Posted October 10, 2016 Author Share Posted October 10, 2016 Brilliant, that's just what I was after (and seems simple now it's laid out for me...) Thanks once again! Link to comment Share on other sites More sharing options...
Recommended Posts