Compute the cross product of two 3D vectors. The cross product produces a vector perpendicular to both input vectors with magnitude equal to the area of the parallelogram they span.
def cross_product(v1: list[float], v2: list[float]) -> list[float]:
x = v1[1] * v2[2] - v1[2] * v2[1]
y = v1[2] * v2[0] - v1[0] * v2[2]
z = v1[0] * v2[1] - v1[1] * v2[0]
return [x, y, z]a = (a1, a2, a3) and b = (b1, b2, b3), the cross product is:a2*b3 - a3*b2a3*b1 - a1*b3a1*b2 - a2*b1|a||b|sin(theta), and it follows the right-hand rule.