Archived

This topic is now archived and is closed to further replies.

giant

Finding the Y Direction of an Object

Recommended Posts

giant    205
If I have an object and I know the following info about it, A vector for its position Its rotation about the X Axis Its rotation about the Y Axis Its rotation about the Z Axis How do I calculate how much it moves in the Y Direction given that I know its speed and the info about. I used Sin and Cos with the X and Z Rotations to find out how much it moves in these directions, but I cant seem to find out the Y direction. Any help would be greatly appreciated. Thanks Giant

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
What if you created a previous position and current position vector. Set the ''prevpos'' to the ''pos'' in the beginning of the loop then, based on input, when prevpos.y != pos.y then you have a translation. When this happens, subtract the previous position from the current position and you have the displacement.

Share this post


Link to post
Share on other sites
giant    205
Hi.

The problem is that I dont know where to move it, in the Y Direction. Because I dont know that I can''t calculate the new position. I have used sin and cos with the rotation angles to fnd out the X and Z directions, so I am guessing that it will be similar to get the Y Direction.

Thanks
Giant

Share this post


Link to post
Share on other sites
granite811    122
I''m assuming what you''re talking about here is some object, like a spaceship, that the player can turn and roll to any rotation, and you want to figure out where the object moves when it goes ''forward''. So, if you were able to get it to work with the X and Y rotations, it''s going to be exactly the same for the Z rotation. Here''s the equation I worked out for it.

dy is change in y position
rotZ is rotation around Z axis
speed is the speed of the object

dy = speed*sin(rotZ)

The only issue is whether you consider positive rotation clockwise, or counter-clockwise. It''s the difference between a right-handed coordinate system, and a left-handed coordinate system. The way to deal with it, though, is try this equation, and if it seems to be funny, just put a minus sign in front of it and see if it fixes it.

Share this post


Link to post
Share on other sites