Re: cos & sin 2d movement

Have you read the API doc for those methods to see how they work?

Re: cos & sin 2d movement

lol thats a helpful answer? course i have, but i will check again now

--- Update ---

what bit other then this do i need to read?

toRadians

public static double toRadians(double angdeg)

Converts an angle measured in degrees to an approximately equivalent angle measured in radians. The conversion from degrees to radians is generally inexact.

Parameters:

angdeg - an angle, in degrees

Returns:

the measurement of the angle angdeg in radians.

Since:

1.2

cos

public static double cos(double a)

Returns the trigonometric cosine of an angle. Special cases:

If the argument is NaN or an infinity, then the result is NaN.

The computed result must be within 1 ulp of the exact result. Results must be semi-monotonic.

Parameters:

a - an angle, in radians.

Returns:

the cosine of the argument.

Re: cos & sin 2d movement

This suggests that you have not read the API doc. Is the 270 degrees or radians?

Re: cos & sin 2d movement

it was degrees. if you look i had a line just above with a variable called radi that i was substituting for angle n other failed attempts.

any way it now works but im not sure why instead of zero values of cos/sin(radian) * speed for the axis not in use it is sin/cos(-2. loads of numbers) * speed(at least 5) = 0; which works fine. I dont know why but ive had a good old drive round of my space ships and there fine

Thank you for your time n e way

John Harris

Re: cos & sin 2d movement

When I called toRadians() with degrees and used its value for the cos() and sin() methods, the results were as expected:
Code :

System.out.println("cos(90)="+Math.cos(Math.toRadians(90)));

Re: cos & sin 2d movement

im trying to do full 360 though maybe my radian knowledge needs revision after 90 what happens in your test? like 180 degrees 270 degree 360/0 degree? cos and sin on each? just to check (and i am sure u know what i mean) but just to check i wanted one axis to say either 1/-1 and the other 0 at these 0/360 90 180 270.

like i say its doing what i ask it but i dont under stand why, please dont waste any more of your time on it though. does that answer return zero? i wonder about the rest but I'm not putting any more time in to it, so please dont worry n e more il come back to it again at some point

Re: cos & sin 2d movement

To see what the values are, write a loop that increments the degrees by 30 and goes from 0 to 360

and prints out three columns of degrees, sin and cos.