Crate hexasphere[][src]

Expand description

Library for subdividing shapes made of triangles.

This library defines Subdivided<T, S>. This struct allows one to define a base shape using S and the BaseShape trait, and to subdivide it using the interpolation functions defined as part of S.

This includes a few base shapes:

  • Icosahedron
  • Tetrahedron
  • Square
  • Triangle
  • Cube

Example usage

use hexasphere::shapes::IcoSphere;

fn main() {
    // Create a new sphere with 20 subdivisions
    // an no data associated with the vertices.
    let sphere = IcoSphere::new(20, |_| ());

    let points = sphere.raw_points();
    for p in points {
        println!("{:?} is a point on the sphere!", p);
    let indices = sphere.get_all_indices();
    for triangle in indices.chunks(3) {
            "[{}, {}, {}] is a triangle on the resulting shape",


  • adjacency allows the user to create neighbour maps from the indices provided by the Subdivided struct.



A progressively subdivided shape which can record the indices of the points and list out the individual triangles of the resulting shape.

A main triangle on the base shape of a subdivided shape.


Defines the setup for a base shape, and the functions used in interpolation.

Implemented in the case where the triangles on the shape are both equilateral and identifiable from their normal.