Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_math/src/primitives/mod.rs
6596 views
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
5
mod dim2;
6
pub use dim2::*;
7
mod dim3;
8
pub use dim3::*;
9
mod polygon;
10
11
/// A marker trait for 2D primitives
12
pub trait Primitive2d {}
13
14
/// A marker trait for 3D primitives
15
pub trait Primitive3d {}
16
17
/// The winding order for a set of points
18
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
19
#[doc(alias = "Orientation")]
20
pub 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
33
pub 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
42
pub 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
}
49
50