This post is part of my Game Math Series.
Cross Product in…2D?
So, the cross product of two 3D vectors is a 3D vector, which is in the direciton of the axis of rotation for rotating the first vector to match the direction of the second vector, with the smallest angle of rotation (always less than 180 degrees). What does “cross product” of 2D vectors mean, then?
I like to think of the “cross product” of two 2D vectors as a scalar, not a vector. How does this work? Basically, treat the 2D vectors like 3D vectors with their z-components equal to zeros, take their cross product, and the final result is the z-component of the cross product. Here’s what the implementation in C++ looks like:
// not the most efficient implementation
float cross(const Vec2 &a, const Vec2 &b)
{
  Vec3 v1(a.x, a.y, 0.0f);
  Vec3 v2(b.x, b.y, 0.0f);
  return cross(v1, v2).z;
}
Since the z-components of the 3D vectors built from 2D ones are zeros, the x-component and y-component of the 3D cross product are zeros. Thus, we can further optimize the implementation:
float cross(const Vec2 &a, const Vec2 &b)
{
  // just calculate the z-component
  return a.x * b.y - a.y * b.x;
}
What’s So Special About It?
Now we’ve see what the cross product of 2D vectors is mathematically, but what does it mean geometrically? As mentioned before, the cross product of two 3D vectors gives you a rotation axis to rotate first vector to match the direction of the second. We’re just extending the 2D space into 3D and perform the cross product, where the two vectors lie on the X-Y plane. The resulting 3D vector is just a rotation axis. However, since the two vectors are on the X-Y plane, this rotation axis would cause rotation only on the X-Y plane, so the axis is always parallel to the Z-axis.
If we reduce our dimension from 3D back to 2D, the rotation axis represents a rotation that is either clockwise (CW) or counter-clockwise (CCW). In other words, The sign of the 2D cross product tells you whether the second vector is on the left or right side of the first vector (the direction of the first vector being front). The absolute value of the 2D cross product is the sine of the angle in between the two vectors, so taking the arc sine of it would give you the angle in radians.
I used cross products of 2D vectors in Astrobunny (my first DigiPen freshmen game project), to decide whether the mouse cursor is on the left or right of the ship and determine which direction to steer.