Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_math/src/primitives/mod.rs
9353 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 inset;
10
pub use inset::*;
11
mod half_space;
12
mod polygon;
13
pub use half_space::*;
14
mod view_frustum;
15
pub use view_frustum::*;
16
17
/// A marker trait for 2D primitives
18
pub trait Primitive2d {}
19
20
/// A marker trait for 3D primitives
21
pub trait Primitive3d {}
22
23
/// The winding order for a set of points
24
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
25
#[doc(alias = "Orientation")]
26
pub 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
39
pub 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
48
pub 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
}
55
56