Problems with cos and sin in Android
- by bajen micke
I have a problem with my code in Android. I am using this to moving a ball. If the degree is 90 it should move to the right, if the degree is 180 it should move down etc.
This is the code I have done.
int degrees=180;
int bollspeed=4;
bollX += bollspeed*Math.cos(Math.toRadians(degrees));
bollY += bollspeed*Math.sin(Math.toRadians(degrees));
The problem is that when the ball should move 90 degrees it moves 180, and when it should move 180 degrees it moves 270. I have tested all I could come to think... Can anyone see any error in my code or have a expanation I would be really glad.
Thanks