# [−][src]Module plexus::primitive

Primitive topological structures.

This module provides composable primitives that can form polygonal structures. This includes simple $n$-gons like triangles, generators that form more complex polytopes like spheres, and iterator expressions that compose and decompose streams of primitives.

Plexus uses the terms trigon and tetragon for its types, which mean triangle and quadrilateral, respectively. This is done for consistency with higher arity polygon names (e.g., decagon). In some contexts, the term triangle is still used, such as in functions concerning triangulation.

Types in this module are not strictly geometric and the data they contain may be arbitrary. For example, polygons are defined in $\Reals^2$, but Polygonal types may be used to approximate polygons embedded into higher-dimensional Euclidean spaces or as simple indices. These types are defined in terms of adjacency.

# Examples

Generating raw buffers with the positional data for a sphere:

use nalgebra::Point3;
use plexus::prelude::*;
use plexus::primitive::generate::Position;
use plexus::primitive::sphere::UvSphere;

let sphere = UvSphere::new(16, 16);

// Generate the unique set of positional vertices.
let positions = sphere
.vertices::<Position<Point3<f64>>>()
.collect::<Vec<_>>();

// Generate polygons that index the unique set of positional vertices.
// The polygons are decomposed into triangles and then into vertices (indices).
let indices = sphere
.indexing_polygons::<Position>()
.triangulate()
.vertices()
.collect::<Vec<_>>();

Generating raw buffers with positional data for a cube using an indexer:

use decorum::N64;
use nalgebra::Point3;
use plexus::index::{Flat3, HashIndexer};
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;

let (indices, positions) = Cube::new()
.polygons::<Position<Point3<N64>>>()
.triangulate()
.index_vertices::<Flat3, _>(HashIndexer::default());

## Modules

 cube Cube primitives. decompose Topological decomposition and tessellation. generate Polytope generation. sphere Sphere primitives.

## Structs

 InteriorMap NGon Homomorphic $n$-gon.

## Enums

 Polygon Polymorphic $n$-gon.

## Traits

 MapVertices Polygonal Primitive polygonal structure. Rotate Topological Primitive topological structure. Zip

## Functions

 zip_vertices Zips the vertices and topologies from multiple iterators into a single iterator.