# Code producing seriously wrong results for co-ords along a circle's radius

hey there i have tried to implement converting between polar co-ordinates and cartesian ones, through using the logger this code outputs the following x,y co-ordinates.

This is for a test between 10 degrees and 0 degrees calculating the x,y coords each angle (at a distance of a 100 units)

oh and i have also cut off everything after the decimal point and i am obviously using the same formula when working it out by hand.

10 degrees should give (98,17) but my code gives (-83,-54)

9 degrees should give (98,15) but my code gives (-91,41)

8 degrees should give (99,13) but my code gives (-14,98)

7 degrees should give (99,12) but my code gives (75,65)

etc

[java] private void buildAsteroids()

{

float d = 100;

float startAngle =10;

float endAngle =0;

Node roidsNode = new Node(“roidsNode”);

Float x,z;

for(float i = startAngle ; i >= endAngle; i–)

{

x = FastMath.cos(i) * d; //see polar co ordinates converting them to cartesian ones

z = FastMath.sin(i) * d;

Box roid = new Box("mockRoid " + i,new Vector3f(x,0,z),

new Vector3f(x+1,0+1,z+1));

roidsNode.attachChild(roid);

logger.warning(“x =” + x + “, z =” + z + ", given for angle = " + i + ", at distance = " + d);[/java]

plz help i have no idea why it would give these results, thank you for any possible help you can give me as of right now im really scratching my head on this one. cheers

Surprise! FastMath uses radians, not degrees.

omg your kidding me lol , fixed and ty so very very much lol 