# movement with respect to angle

## Recommended Posts

anupgupta    128
hello

i would like to know, after changing an object's angle to any random value, as to how do i make the object move in a straight line with respect to that angle.

##### Share on other sites
Aardvajk    13207
Assuming you mean in 2D, firstly construct a normal vector pointing in the direction:

vx=sin(angle);vy=cos(angle);

Then multiply this by the amount you wish to move:

vx*=step;vy*=step;

Then add these to the start position to move step units in the direction:

x+=vx;y+=vy;

##### Share on other sites
jyk    2094
Quote:
 Original post by Aardvajkvx=sin(angle);vy=cos(angle);
Assuming the usual conventions of 0 radians/degrees corresponding to the positive x axis and positive rotations being counterclockwise, 'sin' and 'cos' should be swapped in the above.