bevy_math/
lib.rs

1#![forbid(unsafe_code)]
2#![cfg_attr(
3    any(docsrs, docsrs_dep),
4    expect(
5        internal_features,
6        reason = "rustdoc_internals is needed for fake_variadic"
7    )
8)]
9#![cfg_attr(any(docsrs, docsrs_dep), feature(rustdoc_internals))]
10#![cfg_attr(docsrs, feature(doc_cfg))]
11#![doc(
12    html_logo_url = "https://bevy.org/assets/icon.png",
13    html_favicon_url = "https://bevy.org/assets/icon.png"
14)]
15#![no_std]
16
17//! Provides math types and functionality for the Bevy game engine.
18//!
19//! The commonly used types are vectors like [`Vec2`] and [`Vec3`],
20//! matrices like [`Mat2`], [`Mat3`] and [`Mat4`] and orientation representations
21//! like [`Quat`].
22
23#[cfg(feature = "std")]
24extern crate std;
25
26#[cfg(feature = "alloc")]
27extern crate alloc;
28
29mod affine3;
30mod aspect_ratio;
31pub mod bounding;
32pub mod common_traits;
33mod compass;
34pub mod cubic_splines;
35mod direction;
36mod float_ord;
37mod isometry;
38mod mat3;
39pub mod ops;
40pub mod primitives;
41mod ray;
42mod rects;
43mod rotation2d;
44
45#[cfg(feature = "curve")]
46pub mod curve;
47
48#[cfg(feature = "rand")]
49pub mod sampling;
50
51pub use affine3::*;
52pub use aspect_ratio::AspectRatio;
53pub use common_traits::*;
54pub use compass::{CompassOctant, CompassQuadrant};
55pub use direction::*;
56pub use float_ord::*;
57pub use isometry::{Isometry2d, Isometry3d};
58pub use mat3::*;
59pub use ops::FloatPow;
60pub use ray::{Ray2d, Ray3d};
61pub use rects::*;
62pub use rotation2d::Rot2;
63
64#[cfg(feature = "curve")]
65pub use curve::Curve;
66
67#[cfg(feature = "rand")]
68pub use sampling::{FromRng, ShapeSample};
69
70/// The math prelude.
71///
72/// This includes the most common types in this crate, re-exported for your convenience.
73pub mod prelude {
74    #[doc(hidden)]
75    pub use crate::{
76        bvec2, bvec3, bvec3a, bvec4, bvec4a,
77        cubic_splines::{CubicNurbsError, CubicSegment, RationalSegment},
78        direction::{Dir2, Dir3, Dir3A},
79        ivec2, ivec3, ivec4, mat2, mat3, mat3a, mat4, ops,
80        primitives::*,
81        quat, uvec2, uvec3, uvec4, vec2, vec3, vec3a, vec4, BVec2, BVec3, BVec3A, BVec4, BVec4A,
82        EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Isometry2d, Isometry3d, Mat2, Mat3, Mat3A,
83        Mat4, Quat, Ray2d, Ray3d, Rect, Rot2, StableInterpolate, URect, UVec2, UVec3, UVec4, Vec2,
84        Vec2Swizzles, Vec3, Vec3A, Vec3Swizzles, Vec4, Vec4Swizzles,
85    };
86
87    #[doc(hidden)]
88    #[cfg(feature = "curve")]
89    pub use crate::curve::*;
90
91    #[doc(hidden)]
92    #[cfg(feature = "rand")]
93    pub use crate::sampling::{FromRng, ShapeSample};
94
95    #[cfg(feature = "alloc")]
96    #[doc(hidden)]
97    pub use crate::cubic_splines::{
98        CubicBSpline, CubicBezier, CubicCardinalSpline, CubicCurve, CubicGenerator, CubicHermite,
99        CubicNurbs, CyclicCubicGenerator, RationalCurve, RationalGenerator,
100    };
101}
102
103pub use glam::*;