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\$
1
  • \$\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\$ May 4, 2014 at 8:30

1 Answer 1

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
  • 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, 2014 at 9:48

You must log in to answer this question.

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