pub type FaceQuad<S> = Quad<[S; 3]>;
Expand description
A quad representing a single face of a cuboid.
Aliased Type§
struct FaceQuad<S>(pub [[S; 3]; 4]);
Fields§
§0: [[S; 3]; 4]
Implementations
source§impl<V> Quad<V>where
V: Vertex,
impl<V> Quad<V>where
V: Vertex,
sourcepub fn centroid(&self) -> Vwhere
V: Average,
pub fn centroid(&self) -> Vwhere
V: Average,
Produce the centroid of the quad, aka the “mean”/“average” vertex.
sourcepub fn triangles(&self) -> (Tri<V>, Tri<V>)
pub fn triangles(&self) -> (Tri<V>, Tri<V>)
Triangulates the given quad, represented by four points that describe its edges in either clockwise or anti-clockwise order.
Example
The following rectangle
ⓘ
a b
--------
| |
| |
| |
--------
d c
given as
ⓘ
triangles([a, b, c, d])
returns
ⓘ
(Tri([a, b, c]), Tri([a, c, d]))
Here’s a basic code example:
use nannou::geom::{self, pt2, Quad, Tri};
fn main() {
let a = pt2(0.0, 1.0);
let b = pt2(1.0, 1.0);
let c = pt2(1.0, 0.0);
let d = pt2(0.0, 0.0);
let quad = Quad([a, b, c, d]);
let triangles = geom::quad::triangles(&quad);
assert_eq!(triangles, (Tri([a, b, c]), Tri([a, c, d])));
}
sourcepub fn triangles_iter(&self) -> Triangles<V> ⓘ
pub fn triangles_iter(&self) -> Triangles<V> ⓘ
The same as triangles
but provided as an Iterator.
sourcepub fn bounding_rect(self) -> Rect<<V as Vertex>::Scalar>where
V: Vertex2d,
pub fn bounding_rect(self) -> Rect<<V as Vertex>::Scalar>where
V: Vertex2d,
The bounding Rect
of the quad.
sourcepub fn bounding_cuboid(self) -> Cuboid<<V as Vertex>::Scalar>where
V: Vertex3d,
pub fn bounding_cuboid(self) -> Cuboid<<V as Vertex>::Scalar>where
V: Vertex3d,
The bounding Rect
of the triangle.
sourcepub fn map_vertices<F, V2>(self, map: F) -> Quad<V2>where
F: FnMut(V) -> V2,
pub fn map_vertices<F, V2>(self, map: F) -> Quad<V2>where
F: FnMut(V) -> V2,
Map the Quad’s vertices to a new type.
Trait Implementations
source§impl<V> Into<(V, V, V, V)> for Quad<V>where
V: Vertex,
impl<V> Into<(V, V, V, V)> for Quad<V>where
V: Vertex,
source§fn into(self) -> (V, V, V, V)
fn into(self) -> (V, V, V, V)
Converts this type into the (usually inferred) input type.
impl<V> Eq for Quad<V>where
V: Eq,
impl<V> StructuralPartialEq for Quad<V>
impl<V> StructuralEq for Quad<V>
source§impl<V> From<(V, V, V, V)> for Quad<V>where
V: Vertex,
impl<V> From<(V, V, V, V)> for Quad<V>where
V: Vertex,
source§fn from(_: (V, V, V, V)) -> Quad<V>
fn from(_: (V, V, V, V)) -> Quad<V>
Converts to this type from the input type.