1

I'm working on an IK system, and I'm getting some weird behaviors in cases where an axis of rotation (determined from a cross product) flips. In these cases, I would like to detect

So the question is, given two vectors, A and B, which are both orthogonal to an axis N, is it possible to know for which values cross(A, B) is in the same direction as N, and for which values it is in the opposite direction?

In other words, imagine A and B are vectors in a plane. A is fixed, and B is rotating freely in the plane. Is it possible, only knowing the values of A and B, to know whether cross(A, B) is pointing "into" or "out of" the plane?

sak
  • 123

1 Answers1

1

Presumably, you have a vector $N$ to represent the direction of your axis. If that's the case, then look at the sign of the dot-product $$ \langle A \times B,N \rangle = \operatorname{dot}(\operatorname{cross}(A,B),N) $$ We can also calculate this quantity as the determinant $$ \det \pmatrix{N_1 & N_2 & N_3\\A_1 & A_2 & A_3\\B_1 & B_2 & B_3} $$ If the dot-product is positive, then the vectors are parallel. If the dot-product is negative, then the vectors point in the opposite direction. If the dot product is zero, then something is wrong: either $A$ is parallel/opposite to $B$, or $N$ is in the plane spanned by $A$ and $B$.

Ben Grossmann
  • 225,327