1
\$\begingroup\$

We have two vectors:

  1. Pointing from the floor to a 3d character's head.
  2. Pointing from the character towards where it's facing.

How do I find the vector point from the character towards the right?

The vector has to be orthogonal with the other two but also face in right direction and not to the left.

This is very similar to the question: Determining if something is on the right or left side of an object? But I just want the math to computer the third vector from the first two.

\$\endgroup\$
  • \$\begingroup\$ The operation you're looking for is a "cross product," which creates a vector orthogonal (i.e. 90 degrees) to the other two vectors. mathsisfun.com/algebra/vectors-cross-product.html for a quick study along with pictures to help you understand how the which-side thing works. \$\endgroup\$ – Patrick Hughes May 4 '14 at 8:30
2
\$\begingroup\$

According to the link kindly provided by @Patrick Hughes the answer is this:

cx = ay * bz - az * by
cy = az * bx - ax * bz
cz = ax * by - ay * bx

If the two other vectors are normalized, the resulting vector is also normalized.

Watch out! If you pick the wrong order you may get the wrong direction.

In my case:

UP = A; FRONT = B;
\$\endgroup\$
  • 1
    \$\begingroup\$ Having the two other vectors normalized simply ensures that your new vector will only be dependent on the angle between them and not their size. Even if the 2 vectors aren't normalized, the resulting vector will face the same direction. \$\endgroup\$ – d3dave May 4 '14 at 9:48

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.