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