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.
Shapes define the starting vertices and triangles, as well as the type of interpolation used and thus the smooth shape that is approximated. These provided shapes generate spheres:
shapes::CubeSphere(cube)shapes::IcoSphere(icosahedron)shapes::NormIcoSphere(icosahedron)shapes::TetraSphere(tetrahedron)
Two flat shapes are also provided:
§Example usage
use hexasphere::shapes::IcoSphere;
// 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
adjacencyallows the user to create neighbour maps from the indices provided by theSubdividedstruct.
Modules§
Structs§
- Subdivided
- A subdivided shape generated from some
BaseShapeand a subdivision level. - Triangle
- A main triangle on the base shape of a subdivided shape.
Traits§
- Base
Shape - Defines the geometry of the shape to be subdivided, and the functions used in interpolation.