moving in direction of rotated object, help !
Hi all,
how can i move an object that i''ve just rotated to head in that particular direction ?
my object is rotating from 0 to 6.28 rad ( 0 to 360 deg ).
i''m not looking for a matrix operation, just the x = x * ? + ...
any help on how to proceed would be much appreciated.
Thanks,
Sash
I''m not too sure how you are implementing your algo.
But maybe you could use the equation for a circle to
extrapolate your directional vectors.
Say your object is facing 0 theta.
3PI/2
|
|
|
PI --------->---------- 0, 2PI
|
|
|
PI/2
Ok, cos( 0 ) = 1, sin( 0) = 0
So if you use, x_pos += cos( theta ) and
y_pos += sin( theta )
You are moving in the direction you are facing.
Now say, you rotated to the 3PI/2 direction.
cos( 3PI/2 ) = 0, sin( 3PI/2 ) = -1
x_pos += cos( 3PI/2 ), y_pos += sin( 3PI/2 )
So, your moving in the direction you rotated.
To change you velocity, you might use a magnitude
in the equation so you can move at a given speed.
ex. x_pos += cos( theta ) * magnitude
y_pos += sin( theta ) * magnitude
This should work for 2d, 3d is a little more difficult.
Happy Programming, GUY
But maybe you could use the equation for a circle to
extrapolate your directional vectors.
Say your object is facing 0 theta.
3PI/2
|
|
|
PI --------->---------- 0, 2PI
|
|
|
PI/2
Ok, cos( 0 ) = 1, sin( 0) = 0
So if you use, x_pos += cos( theta ) and
y_pos += sin( theta )
You are moving in the direction you are facing.
Now say, you rotated to the 3PI/2 direction.
cos( 3PI/2 ) = 0, sin( 3PI/2 ) = -1
x_pos += cos( 3PI/2 ), y_pos += sin( 3PI/2 )
So, your moving in the direction you rotated.
To change you velocity, you might use a magnitude
in the equation so you can move at a given speed.
ex. x_pos += cos( theta ) * magnitude
y_pos += sin( theta ) * magnitude
This should work for 2d, 3d is a little more difficult.
Happy Programming, GUY
Adulthood is the vehicle for making you childhood dreams come true.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement