Skip to main content

Module math

Module math 

Source
Expand description

The scalar and vector primitives the rest of the vocabulary is built from: the f32 transcendentals core leaves to a math library, and the 3-component vector ops every layout and transform reaches for.

Modules§

vec3
The crate’s shared 3-component vector math. Every module that needs a dot, cross, or component-wise op reaches for these rather than redeclaring them.

Functions§

acos
Arc cosine, in radians.
asin
Arc sine, in radians.
atan2
Arc tangent of y / x, in radians, using both signs to pick the quadrant.
ceil
Smallest integer at or above x.
cos
Cosine of an angle in radians.
exp
e raised to x.
exp2
2 raised to x.
floor
Largest integer at or below x.
fract
Fractional part, keeping the sign of x.
hypot
Length of the hypotenuse of a right triangle with legs x and y, without the intermediate overflow of sqrt(x * x + y * y).
ln
Natural logarithm.
log2
Base-2 logarithm.
mul_add
x * y + z with a single rounding.
powf
x raised to n.
powi
x raised to the integer power n, by squaring. Matches the expansion f32::powi lowers to rather than routing through powf, which would round differently.
rem_euclid
Least nonnegative remainder of x (mod rhs).
round
Nearest integer, with halves rounded away from zero.
sin
Sine of an angle in radians.
sin_cos
Sine and cosine of an angle in radians.
sqrt
Square root.
tan
Tangent of an angle in radians.
trunc
Integer part, discarding the fraction and keeping the sign of x.