expression

Apply a 2D linear transform

A matrix represents a linear transformation once a basis and multiplication convention are fixed. Here nested arrays store rows, and the mathematical vector is a column. This matrix rotates a point by 90 degrees counterclockwise in a Cartesian y-up plane. Storage layout and vector multiplication convention are separate choices. Expected result (NOT RUN): [-1, 2] Common mistake: Copying a column-major library buffer as rows without translating its layout. This example only handles small integer coordinates. Static Rust example; not a verified ByteMind executable assessment.

Formal Syntax & Structure

rust syntaxrust
result[row] = sum(matrix[row][col] * vector[col])

Working Example

Example Snippetrust
fn apply(m: [[i32; 2]; 2], p: [i32; 2]) -> [i32; 2] {    [m[0][0]*p[0]+m[0][1]*p[1], m[1][0]*p[0]+m[1][1]*p[1]]}fn main() {    let rotation = [[0, -1], [1, 0]];    println!("{:?}", apply(rotation, [2, 1]));}
Rust Reference