#### Archived

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

# Finding the Y Direction of an Object

This topic is 5589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000026
×