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::*;
9#[cfg(feature = "serialize")]
10mod serde;
11
12/// A marker trait for 2D primitives
13pub trait Primitive2d {}
14
15/// A marker trait for 3D primitives
16pub trait Primitive3d {}
17
18/// The winding order for a set of points
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
20#[doc(alias = "Orientation")]
21pub enum WindingOrder {
22    /// A clockwise winding order
23    Clockwise,
24    /// A counterclockwise winding order
25    #[doc(alias = "AntiClockwise")]
26    CounterClockwise,
27    /// An invalid winding order indicating that it could not be computed reliably.
28    /// This often happens in *degenerate cases* where the points lie on the same line
29    #[doc(alias("Degenerate", "Collinear"))]
30    Invalid,
31}
32
33/// A trait for getting measurements of 2D shapes
34pub trait Measured2d {
35    /// Get the perimeter of the shape
36    fn perimeter(&self) -> f32;
37
38    /// Get the area of the shape
39    fn area(&self) -> f32;
40}
41
42/// A trait for getting measurements of 3D shapes
43pub trait Measured3d {
44    /// Get the surface area of the shape
45    fn area(&self) -> f32;
46
47    /// Get the volume of the shape
48    fn volume(&self) -> f32;
49}