Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

maths.wgsl

Import path

Constants

PI

#
const PI: f32 = 3.141592653589793

PI_2

#
const PI_2: f32 = 6.283185307179586

HALF_PI

#
const HALF_PI: f32 = 1.57079632679

FRAC_PI_3

#
const FRAC_PI_3: f32 = 1.0471975512

E

#
const E: f32 = 2.718281828459045

Functions

affine2_to_square

#
fn affine2_to_square ( ) -> mat3x3<f32>

affine3_to_square

#
fn affine3_to_square ( ) -> mat4x4<f32>

mat2x4_f32_to_mat3x3_unpack

#
fn mat2x4_f32_to_mat3x3_unpack ( ) -> mat3x3<f32>

affine3_to_mat3x3

#

Extracts the square portion of an affine matrix: i.e. discards the translation.

fn affine3_to_mat3x3 ( ) -> mat3x3<f32>

inverse_mat3x3

#

Returns the inverse of a 3x3 matrix.

fn inverse_mat3x3 ( ) -> mat3x3<f32>

inverse_affine3

#
fn inverse_affine3 ( ) -> mat4x3<f32>

mat4x4_to_mat3x3

#

Extracts the upper 3x3 portion of a 4x4 matrix.

fn mat4x4_to_mat3x3 ( ) -> mat3x3<f32>

orthonormalize

#
fn orthonormalize (
z_unnormalized: vec3<f32>
) -> mat3x3<f32>

sphere_intersects_plane_half_space

#

This is used for frustum culling.

fn sphere_intersects_plane_half_space (
sphere_center: vec4<f32>
sphere_radius: f32
) -> bool

powsafe

#

pow() but safe for NaNs/negatives

fn powsafe (
power: f32
) -> vec3<f32>

project_onto

#
fn project_onto ( ) -> vec3<f32>

fast_sqrt

#
fn fast_sqrt ( ) -> f32

fast_acos

#

Slightly less accurate than fast_acos_4, but much simpler.

fn fast_acos (
in_x: f32
) -> f32

fast_acos_4

#

4th order polynomial approximation 4 VGRP, 16 ALU Full Rate 7 * 10^-5 radians precision Reference : Handbook of Mathematical Functions (chapter : Elementary Transcendental Functions), M. Abramowitz and I.A. Stegun, Ed.

fn fast_acos_4 ( ) -> f32

fast_atan2

#
fn fast_atan2 ( ) -> f32