cross
Calculates the 2D cross product (also known as the perpendicular dot product or z-component of the 3D cross product) of two 2D vectors.
The 2D cross product is a scalar value calculated as: a.x * b.y - a.y * b.x.
Geometric Interpretation:
The magnitude of this scalar (
abs(a.x * b.y - a.y * b.x)) is equal to the area of the parallelogram formed by the two vectorsaandb.The sign of the result indicates the orientation of vector
brelative to vectora(assuming a standard Cartesian coordinate system where the positive Y-axis is 90 degrees counter-clockwise from the positive X-axis):If
cross(a, b) > 0: vectorbis counter-clockwise from vectora.If
cross(a, b) < 0: vectorbis clockwise from vectora.If
cross(a, b) == 0: vectorsaandbare collinear (i.e., they are parallel or anti-parallel, lying on the same line). This means the area of the parallelogram is zero.
This value is also equivalent to the z-component of the 3D cross product if a and b were considered as 3D vectors in the xy-plane (i.e., A = (a.x, a.y, 0) and B = (b.x, b.y, 0)). The 3D cross product A x B would be (0, 0, a.x*b.y - a.y*b.x).
It is related to the sine of the angle θ between the vectors: cross(a,b) = |a| |b| sin(θ), where θ is the signed angle from a to b.
Return
The scalar 2D cross product as a Float.
Parameters
The first 2D vector.
The second 2D vector.