[SOLVED] How to know the rotation ?

Hello,
when i use ActionScript in Flash i use this code to make an object move forward depending on it’s rotation :


public static function moveForward (o1:Object, s:Number)
		{
			o1.x = o1.x + Math.cos(o1.rotation / 180 * Math.PI) * s;
			o1.y = o1.y + Math.sin(o1.rotation / 180 * Math.PI) * s;
		}

how can i find the rotation of an object ?

What information about the object do you currently have? Is it an instance of your own class? Do you know anything about its velocity?

It sounds like you will need to be storing some information within these objects, such as the direction they are currently moving.

How can you find the rotation of an object?

Do you have a class for that type of object which holds its variables such as position and speed? Do you have any Java code? Do you know any Java?

I know some ActionScript, and I know why you would think that an image has a rotation you can get from it, but Java doesn’t work that way.

Shouldn’t it be


Math.sin(-1 * o1.rotation / 180 * Math.PI)

Isn’t the y-axis inverted?

Coordinate frame convention dictates.

Usually you give the rotation to the object. You say your Zombie now walks in this direction, your player heads towards the mouse, etc.

I don’t really understand what you mean by finding the rotation?

Maybe rotation relative to x axis? atan2(dy, dx) * 180 / pi?

sorry guys i didn’t mark this topic [solved]
it seems that i wasn’t understanding a lot of thing when i write this topic ::slight_smile:
anyway,
i made an easy tutorial about rotating and moving toward direction, you can see it (and correct it) here

thank you