Skip to main content

bevy_math/primitives/
mod.rs

1//! This module defines primitive shapes.
2//! The origin is (0, 0) for 2D primitives and (0, 0, 0) for 3D primitives,
3//! unless stated otherwise.
4
5mod dim2;
6pub use dim2::*;
7mod dim3;
8pub use dim3::*;
9mod inset;
10pub use inset::*;
11mod half_space;
12mod polygon;
13pub use half_space::*;
14mod view_frustum;
15pub use view_frustum::*;
16
17/// A marker trait for 2D primitives
18pub trait Primitive2d {}
19
20/// A marker trait for 3D primitives
21pub trait Primitive3d {}
22
23/// The winding order for a set of points
24#[derive(Clone, Copy, Debug, PartialEq, Eq)]
25#[doc(alias = "Orientation")]
26pub enum WindingOrder {
27    /// A clockwise winding order
28    Clockwise,
29    /// A counterclockwise winding order
30    #[doc(alias = "AntiClockwise")]
31    CounterClockwise,
32    /// An invalid winding order indicating that it could not be computed reliably.
33    /// This often happens in *degenerate cases* where the points lie on the same line
34    #[doc(alias("Degenerate", "Collinear"))]
35    Invalid,
36}
37
38/// A trait for getting measurements of 2D shapes
39pub trait Measured2d {
40    /// Get the perimeter of the shape
41    fn perimeter(&self) -> f32;
42
43    /// Get the area of the shape
44    fn area(&self) -> f32;
45}
46
47/// A trait for getting measurements of 3D shapes
48pub trait Measured3d {
49    /// Get the surface area of the shape
50    fn area(&self) -> f32;
51
52    /// Get the volume of the shape
53    fn volume(&self) -> f32;
54}