[][src]Struct nannou::geom::quad::Quad

pub struct Quad<V = Default>(pub [V; 4]);

A quad represented by its four vertices.

Implementations

impl<V> Quad<V> where
    V: Vertex
[src]

pub fn vertices(self) -> Vertices<V>

Notable traits for Vertices<V>

impl<V> Iterator for Vertices<V> where
    V: Clone
type Item = V;
[src]

Produce an iterator yielding each vertex in the Quad.

pub fn centroid(&self) -> V where
    V: EuclideanSpace
[src]

Produce the centroid of the quad, aka the "mean"/"average" vertex.

pub fn triangles(&self) -> (Tri<V>, Tri<V>)[src]

Triangulates the given quad, represented by four points that describe its edges in either clockwise or anti-clockwise order.

Example

The following rectangle

This example is not tested
 a        b
  --------
  |      |
  |      |
  |      |
  --------
 d        c

given as

This example is not tested
triangles([a, b, c, d])

returns

This example is not tested
(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])));
}

pub fn triangles_iter(&self) -> Triangles<V>

Notable traits for Triangles<V>

impl<V> Iterator for Triangles<V> type Item = Tri<V>;
[src]

The same as triangles but provided as an Iterator.

pub fn bounding_rect(self) -> Rect<V::Scalar> where
    V: Vertex2d
[src]

The bounding Rect of the quad.

pub fn bounding_cuboid(self) -> Cuboid<V::Scalar> where
    V: Vertex3d
[src]

The bounding Rect of the triangle.

pub fn map_vertices<F, V2>(self, map: F) -> Quad<V2> where
    F: FnMut(V) -> V2, 
[src]

Map the Quad's vertices to a new type.

Methods from Deref<Target = [V; 4]>

pub fn as_slice(&self) -> &[T]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
[src]

🔬 This is a nightly-only experimental API. (array_methods)

Returns a slice containing the entire array. Equivalent to &s[..].

Trait Implementations

impl<V> AsRef<[V; 4]> for Quad<V> where
    V: Vertex
[src]

impl<V> AsRef<Quad<V>> for Quad<V> where
    V: Vertex
[src]

impl<V: Clone> Clone for Quad<V>[src]

impl<V: Copy> Copy for Quad<V>[src]

impl<V: Debug> Debug for Quad<V>[src]

impl<V> Deref for Quad<V>[src]

type Target = [V; 4]

The resulting type after dereferencing.

impl<V: Eq> Eq for Quad<V>[src]

impl<V> From<[V; 4]> for Quad<V> where
    V: Vertex
[src]

impl<V> From<(V, V, V, V)> for Quad<V> where
    V: Vertex
[src]

impl<S> From<Quad<Vector2<S>>> for Quad<S> where
    S: BaseFloat
[src]

impl<V: Hash> Hash for Quad<V>[src]

impl<V> Index<usize> for Quad<V> where
    V: Vertex
[src]

type Output = V

The returned type after indexing.

impl<V> Into<[V; 4]> for Quad<V> where
    V: Vertex
[src]

impl<V> Into<(V, V, V, V)> for Quad<V> where
    V: Vertex
[src]

impl<V: PartialEq> PartialEq<Quad<V>> for Quad<V>[src]

impl<V> StructuralEq for Quad<V>[src]

impl<V> StructuralPartialEq for Quad<V>[src]

Auto Trait Implementations

impl<V> RefUnwindSafe for Quad<V> where
    V: RefUnwindSafe

impl<V> Send for Quad<V> where
    V: Send

impl<V> Sync for Quad<V> where
    V: Sync

impl<V> Unpin for Quad<V> where
    V: Unpin

impl<V> UnwindSafe for Quad<V> where
    V: UnwindSafe

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> NodeId for T where
    T: 'static + Copy + Clone + PartialEq<T> + Eq + Hash + Send
[src]

impl<T> SetParameter for T

impl<T> Style for T where
    T: Any + Debug + PartialEq<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,