1
\$\begingroup\$

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.

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

1 Answer 1

12
\$\begingroup\$

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)
left_dir=-right

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

\$\endgroup\$
4
  • \$\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, 2012 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, 2012 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, 2012 at 8:56
  • 4
    \$\begingroup\$ +1 for "Imagine being a falling raindrop" for both illustrating the point and being sort of poetic. \$\endgroup\$ Oct 18, 2012 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .