I have a position vector of a point in space and a quaternion for it's rotation. What i'm trying to calculate is a point too the left and a point to the right.

Image showing what I want to achieve

I have the position and rotation(quaternion) of the red dot. What I want is to get the position of the green dots. I have a float value for the distance I want these points to be.

With only the position and rotation is it possible to get a unit direction vector pointing left/right which I can multiply by my float value?

Edit: I also know the original direction vector.

  • \$\begingroup\$ Do you have the Direction vector and any fixed Vector (like UP)? \$\endgroup\$
    – 0xBADF00D
    Oct 18 '12 at 8:14
  • \$\begingroup\$ I have the original direction vector. (edited question) \$\endgroup\$ Oct 18 '12 at 8:44

Given only a point and a direction there is no defined 'right' or 'left'.

Imagine being a falling raindrop, which direction is right or left for you in that case?

In order to calculate (or even define) a right or left you need two directions, typically forward and up.

You seem to already have a forward direction, so you need to define a up direction.

right_dir=forward X up  (cross product)

As you want unit vectors in these direction, you should of course normalize right & left.

  • \$\begingroup\$ I know the up direction. I also realized I know the first direction it's facing. Can I use my rotation and the vector to calculate the new forward vector and then do as you have suggested? If I can get the angle I can use the dot product with the original direction to get the new direction I think. \$\endgroup\$ Oct 18 '12 at 8:44
  • \$\begingroup\$ I assume all this is in 3D. If you have a quaternion, you can apply that to both the original forward direction and original up direction, to give you a new forward and new up. Get the cross product of the two new vectors. \$\endgroup\$
    – Ken
    Oct 18 '12 at 8:47
  • \$\begingroup\$ Excellent, thank you. I'll give it a go and mark it as the answer if it works. \$\endgroup\$ Oct 18 '12 at 8:56
  • 3
    \$\begingroup\$ +1 for "Imagine being a falling raindrop" for both illustrating the point and being sort of poetic. \$\endgroup\$ Oct 18 '12 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.