How to get the direction for moving "sideways" in 3D space?

165 Views Asked by At

I am not entirely sure on how to phrase this question.

Imagine I have an object in 3D space. I got its position, the rotation and the direction it is facing each represented as a vector.

Now I want to move this object sideways, to the left and to the right.

How do I calculate the direction vector I have to move?

1

There are 1 best solutions below

0
On

I figured it out. I try to explain it to the best of my abilities, however I am not great at maths.

  1. create a plane using the normal vector (0,1,0)
  2. set the quaternion (rotation) of the plane to the rotation of the object you want to move
  3. get the new normal vector of the plane
  4. finally calculate the cross vector of the new normal vector and the vector which represents the direction your object is facing.

I created a function which does exactly this using threeJS

I would be happy for suggestions and it would be great if someone could format this answer properly, for I don't know how to write this properly. Thank you guys for the help :)