Skip to main content

Module camera_math

Module camera_math 

Source
Expand description

Per-frame camera state for the pinhole projection the renderer uses.

A Camera carries an f64 world position and an orthonormal right / down / forward basis. Rendering happens in f32, so [derive] narrows the basis once per frame and precomputes the four view-frustum corner ray directions.

§Pinhole model

A pixel (px, py) maps to a ray direction

dir = (px - hx)·right + (py - hy)·down + hz·forward

where (hx, hy) is the projection centre in pixels and hz the focal length. (hx, hy, hz) = (w/2, h/2, w/2) gives a 90° horizontal field of view with square pixels. The same expression evaluated at the four screen corners yields CameraState::corn.

Structs§

CameraState
Per-frame f32 camera state derived from a Camera + the screen projection parameters.

Functions§

derive
Derive the per-frame CameraState for an xres × yres framebuffer with projection centre (hx, hy) and focal length hz.