I would like to show the radians from 0 to 3.14 an from 3.14 to -0.1.
how could i do that ?
thanks
This is a simple math question.
If you have more than 6.28 , you can do this :
if(radians > ( Math.PI * 2 ) ) { radians = radians%(Math.PI*2); } ;
easy as pie.
thats very usefull radians%(Math.PI*2)
that percent symbol % , i never new that.
thanks for that.
so why does it return a value greater than 6.28 ?
That percent sign is called a Modulo operator - very useful for finding angles, determining multiples, and finding even and odd integers. It's also important for Flash, since Flash has a display object rotation bug - you cannot simply increase an object's rotation indefinately, Flash will eventually freeze the rotating image in place.
As for why Box2D returns angles greater than 2*pi, it's just one less calculation, and technically the angle returned is more 'true' - i.e. it's 22 rotations past it's origin point (which may be important for some applications).
Simple enough fix though - go into the b2Body class, find the GetAngle function, and toss that modulo equation in before the return command. From then on, you'll never have to translate GetAngle into a specific range ever again. But you may encounter other problems! Use at your own risk!