Skip to main content

Module math

Module math 

Source
Expand description

Linear algebra primitives, color types, and bit-manipulation utilities.

Provides Vec2, Vec3, and Vec4 floating-point vectors with swizzle accessors, scalar-valued color types (R8U, R32F, Rg8U, Rg32F, Rgb8U, Rgb32F, Rgba8U, Rgba32F, Rgb565, Yiq32F), axis-aligned bounding regions (Region3, Rect), bit-interleaving helpers, and PCA-based axis estimation.

Structs§

R8U
A single-channel 8-bit unsigned color (red).
R32F
A single-channel color represented as one f32.
Rect
An axis-aligned rectangle.
Region2
A region in 2D space defined by a points on a diagonal.
Region3
A region in 3D space defined by a points on a diagonal.
Rg8U
A two-channel 8-bit unsigned color (red, green).
Rg32F
A two-channel (red, green) color represented as 2 f32s.
Rgb8U
An RGB color with 8 bit unsigned normalized integers per channel.
Rgb32F
An RGB color represented as 3 floats.
Rgb565
An RGB color with 5,6 and 5 bits unsigned normalized integers per channel.
Rgba8U
An RGBA color with 8 bit unsigned normalized integers per channel.
Rgba32F
An RGBA color represented as 4 f32s.
Vec2
A 2D vector.
Vec3
A 3D vector.
Vec4
A 4D vector.
Yiq32F
An YIQ color represented as 3 floats.

Traits§

Delta
Delta allows calculating “difference” between base and current value, and reconstructing current value from base and delta.
One
Trait to create multiplicative identity element.
Vector
Zero
Trait to create additive identity element.

Functions§

compact6_3
Extracts every-third bit from a 16-bit value back into 6 bits.
compact8_2
Extracts even bit positions from a 16-bit value back into 8 bits.
compact8_3
Extracts every-third bit from a value back into 8 bits.
compact8_4
Extracts every-fourth bit from a 32-bit value back into 8 bits.
compact16_2
Extracts even bit positions from a 32-bit value back into 16 bits.
compact32_2
Extracts even bit positions from a 64-bit value back into 32 bits.
deinterleave8_2
Deinterleaves a 16-bit Morton code into two 8-bit values.
deinterleave8_3
Deinterleaves a 24-bit Morton code into three 8-bit values.
deinterleave8_4
Deinterleaves a 32-bit Morton code into four 8-bit values.
deinterleave16_2
Deinterleaves a 32-bit Morton code into two 16-bit values.
deinterleave32_2
Deinterleaves a 64-bit Morton code into two 32-bit values.
deinterleave655_3
Deinterleaves a 16-bit Morton code into three values (6, 5, 5 bits).
interleave8_2
Interleaves the bits of two 8-bit values into a 16-bit Morton code.
interleave8_3
Interleaves the bits of three 8-bit values into a 24-bit Morton code.
interleave8_4
Interleaves the bits of four 8-bit values into a 32-bit Morton code.
interleave16_2
Interleaves the bits of two 16-bit values into a 32-bit Morton code.
interleave32_2
Interleaves the bits of two 32-bit values into a 64-bit Morton code.
interleave655_3
Interleaves three values (6, 5, 5 bits) into a 16-bit Morton code.
lerp
Linearly interpolates between a and b by factor t.
max_variance_diagonal_axis2
Returns the bounding-box diagonal axis along which the given samples have the greatest variance.
max_variance_diagonal_axis3
Returns the bounding-box diagonal axis along which the given samples have the greatest variance.
pca_axis2
Estimates the principal component axis of a set of 3D points via power iteration on the covariance matrix.
pca_axis3
Estimates the principal component axis of a set of 3D points via power iteration on the covariance matrix.
round_down
Rounds value down to the nearest multiple of round.
round_up
Rounds value up to the nearest multiple of round.
spread6_3
Spreads 6 bits into every-third bit position of a 16-bit value.
spread8_2
Spreads 8 bits into even bit positions of a 16-bit value.
spread8_3
Spreads 8 bits into every-third bit position of a 24-bit value.
spread8_4
Spreads 8 bits into every-fourth bit position of a 32-bit value.
spread16_2
Spreads 16 bits into even bit positions of a 32-bit value.
spread32_2
Spreads 32 bits into even bit positions of a 64-bit value (2-way interleave building block).