The cross product is computed component by component using the cyclic pattern. The check that both original vectors are perpendicular to the result (dot product = 0) verifies correctness.
About Cross Product
The cross product of two 3D vectors a=โจa1โ,a2โ,a3โโฉ and b=โจb1โ,b2โ,b3โโฉ is a new vector aรb that is perpendicular to both a and b. Its magnitude equals the area of the parallelogram formed by a and b.