meshx/ops/
mod.rs

1pub mod transform;
2
3pub use transform::*;
4
5use crate::bbox::BBox;
6
7pub trait Empty {
8    /// Construct an empty object.
9    fn empty() -> Self;
10    /// Check if this object is empty.
11    fn is_empty(&self) -> bool;
12}
13
14pub trait Contains<RHS = Self> {
15    /// Check if this object contains another.
16    fn contains(&self, obj: RHS) -> bool;
17}
18
19pub trait Absorb<RHS = Self> {
20    type Output;
21
22    /// Absorb another object.
23    /// For example if a = [-1, 2] and b = [3, 4] is are closed intervals,
24    /// then a.absorb(b) == [-1 4].
25    fn absorb(self, rhs: RHS) -> Self::Output;
26}
27
28/// Intersection trait, describes the intersection operation between two objects.
29pub trait Intersect<RHS = Self> {
30    type Output;
31
32    /// Intersect on one object with another, producing the resulting intersection.
33    /// For example if [-1, 2] and [0, 4] are two closed intervals, then their
34    /// intersection is a closed interval [0, 2].
35    /// Note that the intersection object can be of a different type
36    fn intersect(self, rhs: RHS) -> Self::Output;
37
38    /// Check if this object intersects another.
39    fn intersects(self, rhs: RHS) -> bool;
40}
41
42pub trait Centroid<T> {
43    /// Compute the centroid of the object.
44    fn centroid(self) -> T;
45}
46
47pub trait Area<T> {
48    /// Compute the area of the object.
49    fn area(self) -> T;
50
51    /// Compute the signed area of the object. The area is negative when
52    /// the object is inverted.
53    fn signed_area(self) -> T;
54}
55
56pub trait Volume<T> {
57    /// Compute the volume of the object.
58    fn volume(self) -> T;
59
60    /// Compute the signed volume of the object. The volume is negative when
61    /// the object is inverted.
62    fn signed_volume(self) -> T;
63}
64
65/// Shape matrices are useful for finite element analysis.
66pub trait ShapeMatrix<M> {
67    /// Return a shape matrix of the given type `M`.
68    fn shape_matrix(self) -> M;
69}
70
71pub trait Normal<T> {
72    /// Compute the unit normal of this object.
73    fn normal(self) -> T;
74}
75
76pub trait BoundingBox<T> {
77    /// Compute the bounding box of this object.
78    fn bounding_box(&self) -> BBox<T>;
79}
80
81pub trait Skew {
82    type Output;
83    /// Produce a skew form of self. For instance a 3D vector can be rearranged in a skew symmetric
84    /// matrix, that corresponds to the cross product operator.
85    fn skew(&self) -> Self::Output;
86}