# Crate hexasphere

source ·## 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) {
println!(
"[{}, {}, {}] is a triangle on the resulting shape",
triangle[0],
triangle[1],
triangle[2],
);
}
}
```

## §Features

`adjacency`

allows the user to create neighbour maps from the indices provided by the`Subdivided`

struct.

## Modules§

## Structs§

- 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.

## Traits§

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