Skip to main content

Module math

Module math 

Source
Expand description

Small vector and matrix helpers for the 3D viewer and the thumbnail renderer. Vectors are [f32; 3]; matrices are column-major [[f32; 4]; 4] (m[column][row]), as WGSL reads them. The camera space is right-handed (the camera looks down −Z) and clip depth runs from 0 (near) to 1 (far), as wgpu expects.

Functions§

add
cross
dot
length
look_at
The view matrix of a camera at eye looking at center with up pointing up the screen.
mul
normalize
a scaled to length 1; the zero vector stays zero.
orthographic
An orthographic projection showing half_h units above and below the centre of the screen.
perspective
A perspective projection: fovy is the vertical field of view in radians, aspect width over height.
rotate_about
p turned by angle radians about the axis through origin along the unit vector axis, counter-clockwise looking down the axis (Rodrigues).
scale
sub
transform_point
m applied to the point p, after the divide by w.

Type Aliases§

M4
V3