expression
Calculate a right-handed surface normal
The three-dimensional cross product produces a vector perpendicular to both operands. Its orientation follows a right-handed convention; reversing the operands reverses the normal. Its magnitude also reflects the parallelogram area. Parallel vectors produce zero, so a degenerate triangle has no unit normal. Expected result (NOT RUN): [0, 0, 1] [0, 0, -1] Common mistake: Ignoring vertex winding or assuming the cross product always has unit length. This integer fixture uses small inputs only. Static Rust example; not a verified ByteMind executable assessment.
Formal Syntax & Structure
rust syntaxrust
cross(a, b) -> [a_y*b_z-a_z*b_y, ...]Working Example
Example Snippetrust
fn cross(a: [i32; 3], b: [i32; 3]) -> [i32; 3] { [a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]]}fn main() { let a = [1, 0, 0]; let b = [0, 1, 0]; println!("{:?}", cross(a, b)); println!("{:?}", cross(b, a));}