pub fn triangles<V>(q: &Quad<V>) -> (Tri<V>, Tri<V>)where
V: Vertex,
Expand description
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])));
}