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

Primitive topological structures.

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

Types in this module generally describe cycle graphs and are not strictly geometric. For example, Polygonal types may be geometrically degenerate (e.g., collinear, converged, etc.) or used to approximate polygons from $\Reals^2$ embedded into higher-dimensional Euclidean spaces. These types are also used for indexing, in which case their representation and data are both entirely topological.

Plexus uses the terms trigon and tetragon for its polygon 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.

# Examples

Generating raw buffers with the positional data for a sphere approximation:

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, where each
// vertex is an index into the position data.
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 Monomorphic $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.