Crate math

Source
Expand description

Provides math types and functionality for the Bevy game engine.

The commonly used types are vectors like Vec2 and Vec3, matrices like Mat2, Mat3 and Mat4 and orientation representations like Quat.

Modules§

bool
bool vector mask types.
bounding
This module contains traits and implements for working with bounding shapes
common_traits
This module contains abstract mathematical traits shared by types used in bevy_math.
cubic_splines
Provides types for building cubic splines for rendering curves and use with animation easing.
curvecurve
The Curve trait, providing a domain-agnostic description of curves.
f32
f32 vector, quaternion and matrix types.
f64
f64 vector, quaternion and matrix types.
i8
i8 vector types.
i16
i16 vector types.
i32
i32 vector types.
i64
i64 vector types.
prelude
The math prelude.
primitives
This module defines primitive shapes. The origin is (0, 0) for 2D primitives and (0, 0, 0) for 3D primitives, unless stated otherwise.
samplingrand
This module contains tools related to random sampling.
swizzles
Traits adding swizzle methods to all vector types.
u8
u8 vector types.
u16
u16 vector types.
u32
u32 vector types.
u64
u64 vector types.

Structs§

Affine2
A 2D affine transform, which can represent translation, rotation, scaling and shear.
Affine3
Reduced-size version of glam::Affine3A for use when storage has significant performance impact. Convert to glam::Affine3A to do non-trivial calculations.
Affine3A
A 3D affine transform, which can represent translation, rotation, scaling and shear.
AspectRatio
An AspectRatio is the ratio of width to height.
BVec2
A 2-dimensional bool vector mask.
BVec3
A 3-dimensional bool vector mask.
BVec4
A 4-dimensional bool vector mask.
BVec3A
A 3-dimensional SIMD vector mask.
BVec4A
A 4-dimensional SIMD vector mask.
DAffine2
A 2D affine transform, which can represent translation, rotation, scaling and shear.
DAffine3
A 3D affine transform, which can represent translation, rotation, scaling and shear.
DMat2
A 2x2 column major matrix.
DMat3
A 3x3 column major matrix.
DMat4
A 4x4 column major matrix.
DQuat
A quaternion representing an orientation.
DVec2
A 2-dimensional vector.
DVec3
A 3-dimensional vector.
DVec4
A 4-dimensional vector.
Dir2
A normalized vector pointing in a direction in 2D space
Dir3
A normalized vector pointing in a direction in 3D space
Dir3A
A normalized SIMD vector pointing in a direction in 3D space.
FloatOrd
A wrapper for floats that implements Ord, Eq, and Hash traits.
I8Vec2
A 2-dimensional vector.
I8Vec3
A 3-dimensional vector.
I8Vec4
A 4-dimensional vector.
I16Vec2
A 2-dimensional vector.
I16Vec3
A 3-dimensional vector.
I16Vec4
A 4-dimensional vector.
I64Vec2
A 2-dimensional vector.
I64Vec3
A 3-dimensional vector.
I64Vec4
A 4-dimensional vector.
IRect
A rectangle defined by two opposite corners.
IVec2
A 2-dimensional vector.
IVec3
A 3-dimensional vector.
IVec4
A 4-dimensional vector.
Isometry2d
An isometry in two dimensions, representing a rotation followed by a translation. This can often be useful for expressing relative positions and transformations from one position to another.
Isometry3d
An isometry in three dimensions, representing a rotation followed by a translation. This can often be useful for expressing relative positions and transformations from one position to another.
Mat2
A 2x2 column major matrix.
Mat3
A 3x3 column major matrix.
Mat4
A 4x4 column major matrix.
Mat3A
A 3x3 column major matrix.
Quat
A quaternion representing an orientation.
Ray2d
An infinite half-line starting at origin and going in direction in 2D space.
Ray3d
An infinite half-line starting at origin and going in direction in 3D space.
Rect
A rectangle defined by two opposite corners.
Rot2
A counterclockwise 2D rotation.
U8Vec2
A 2-dimensional vector.
U8Vec3
A 3-dimensional vector.
U8Vec4
A 4-dimensional vector.
U16Vec2
A 2-dimensional vector.
U16Vec3
A 3-dimensional vector.
U16Vec4
A 4-dimensional vector.
U64Vec2
A 2-dimensional vector.
U64Vec3
A 3-dimensional vector.
U64Vec4
A 4-dimensional vector.
URect
A rectangle defined by two opposite corners.
UVec2
A 2-dimensional vector.
UVec3
A 3-dimensional vector.
UVec4
A 4-dimensional vector.
Vec2
A 2-dimensional vector.
Vec3
A 3-dimensional vector.
Vec4
A 4-dimensional vector.
Vec3A
A 3-dimensional vector.

Enums§

CompassOctant
A compass enum with 8 directions.
CompassQuadrant
A compass enum with 4 directions.
EulerRot
Euler rotation sequences.
InvalidDirectionError
An error indicating that a direction is invalid.

Traits§

Curve
A trait for a type that can represent values of type T parametrized over a fixed interval.
FloatExt
A trait for extending f32 and f64 with extra methods.
FloatPow
This extension trait covers shortfall in determinacy from the lack of a libm counterpart to f32::powi. Use this for the common small exponents.
FromRng
Ergonomics trait for a type with a Standard distribution, allowing values to be generated uniformly from an Rng by a method in its own namespace.
NormedVectorSpace
A type that supports the operations of a normed vector space; i.e. a norm operation in addition to those of VectorSpace. Specifically, the implementor must guarantee that the following relationships hold, within the limitations of floating point arithmetic:
ShapeSample
Exposes methods to uniformly sample a variety of primitive shapes.
StableInterpolate
A type with a natural interpolation that provides strong subdivision guarantees.
Vec2Swizzles
Vec3Swizzles
Vec4Swizzles
VectorSpace
A type that supports the mathematical operations of a real vector space, irrespective of dimension. In particular, this means that the implementing type supports:

Functions§

bvec2
Creates a 2-dimensional bool vector mask.
bvec3
Creates a 3-dimensional bool vector mask.
bvec4
Creates a 4-dimensional bool vector mask.
bvec3a
Creates a 3-dimensional bool vector mask.
bvec4a
Creates a 4-dimensional bool vector mask.
dmat2
Creates a 2x2 matrix from two column vectors.
dmat3
Creates a 3x3 matrix from three column vectors.
dmat4
Creates a 4x4 matrix from four column vectors.
dquat
Creates a quaternion from x, y, z and w values.
dvec2
Creates a 2-dimensional vector.
dvec3
Creates a 3-dimensional vector.
dvec4
Creates a 4-dimensional vector.
i8vec2
Creates a 2-dimensional vector.
i8vec3
Creates a 3-dimensional vector.
i8vec4
Creates a 4-dimensional vector.
i16vec2
Creates a 2-dimensional vector.
i16vec3
Creates a 3-dimensional vector.
i16vec4
Creates a 4-dimensional vector.
i64vec2
Creates a 2-dimensional vector.
i64vec3
Creates a 3-dimensional vector.
i64vec4
Creates a 4-dimensional vector.
ivec2
Creates a 2-dimensional vector.
ivec3
Creates a 3-dimensional vector.
ivec4
Creates a 4-dimensional vector.
mat2
Creates a 2x2 matrix from two column vectors.
mat3
Creates a 3x3 matrix from three column vectors.
mat4
Creates a 4x4 matrix from four column vectors.
mat3a
Creates a 3x3 matrix from three column vectors.
quat
Creates a quaternion from x, y, z and w values.
u8vec2
Creates a 2-dimensional vector.
u8vec3
Creates a 3-dimensional vector.
u8vec4
Creates a 4-dimensional vector.
u16vec2
Creates a 2-dimensional vector.
u16vec3
Creates a 3-dimensional vector.
u16vec4
Creates a 4-dimensional vector.
u64vec2
Creates a 2-dimensional vector.
u64vec3
Creates a 3-dimensional vector.
u64vec4
Creates a 4-dimensional vector.
uvec2
Creates a 2-dimensional vector.
uvec3
Creates a 3-dimensional vector.
uvec4
Creates a 4-dimensional vector.
vec2
Creates a 2-dimensional vector.
vec3
Creates a 3-dimensional vector.
vec4
Creates a 4-dimensional vector.
vec3a
Creates a 3-dimensional vector.

Type Aliases§

Direction2dDeprecated
A normalized vector pointing in a direction in 2D space
Direction3dDeprecated
A normalized vector pointing in a direction in 3D space