Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

std::math

ItemSummary
PIThe ratio of a circle’s circumference to its diameter, about 3.14159
TAUA full turn in radians, equal to 2.0 * PI (about 6.28319)
EEuler’s number, the base of the natural logarithm, about 2.71828

Constants

PI

const PI: float

The ratio of a circle’s circumference to its diameter, about 3.14159. An angle of PI radians is half a turn.

TAU

const TAU: float

A full turn in radians, equal to 2.0 * PI (about 6.28319).

E

const E: float

Euler’s number, the base of the natural logarithm, about 2.71828.

Types

Vec2

A 2D vector with float components x and y. Create one with Vec2::new(x, y) or a struct literal such as Vec2 { x = 1.0, y = 2.0 }.

Vec3

A 3D vector with float components x, y, and z. Create one with a struct literal such as Vec3 { x = 0.0, y = 1.0, z = 0.0 }.

Quat

A rotation in 3D space, stored as a quaternion with float components x, y, z, and w. Scripts usually create one with Quat::from_rotation_z and pass it to the host, such as for the rotation of a Bevy transform.