A cross product is a way to find a vector that’s at a right angle to two other vectors.
In the image below, we want to get the “C” vector by using the “A” and “B” vectors.

The math is pretty simple. I’ve added a piece of code to calc the C vector from the A B. Passing in an out vector will fill in the cross product for you.
private void CrossProduct(Vector3 a, Vector3 b, out Vector3 c)
{
c.x = (a.y * b.z) - (a.z * b.y);
c.y = (a.z * b.x) - (a.x * b.z);
c.z = (a.x * b.y) - (a.y * b.x);
}

The yellow ball shows the direction of the cross product from the angle between the A B vectors



Leave a comment