[−][src]Crate hexasphere
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::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 theSubdivided
struct.
Structs
CubeBase | Implements a cube as the base shape. |
IcoSphereBase | Implements an icosahedron as the base shape. |
SquareBase | Implements a square as the base shape. |
Subdivided | A progressively subdivided shape which can record the indices of the points and list out the individual triangles of the resulting shape. |
TetraSphereBase | Implements a tetrahedron as the base shape. |
Triangle | A main triangle on the base shape of a subdivided shape. |
TriangleBase | Implements a single triangle as the base shape. |
Traits
BaseShape | Defines the setup for a base shape, and the functions used in interpolation. |
EquilateralBaseShape | Implemented in the case where the triangles on the shape are both equilateral and identifiable from their normal. |
Functions
geometric_slerp | Implements spherical interpolation along the great arc created by
the initial points. This returns a new point |
geometric_slerp_half | This is an optimization for the |
geometric_slerp_multiple | This is an optimization for the case where multiple points require the
calculation of varying values of |
lerp | Simple linear interpolation. No weirdness here. |
lerp_half | Gives the average of the two points. |
lerp_multiple | This is provided as a plug in for people who need it, but this implements
essentially the same algorithm as |
normalized_lerp | Performs normalized linear interpolation. This creates distortion when compared with spherical interpolation along an arc, however this is most likely faster, as though this avoids expensive sin and acos calculations. |
normalized_lerp_half | This is an optimization of |
normalized_lerp_multiple | This is provided as a plug in for people who need it, but this implements
essentially the same algorithm as |
Type Definitions
CubeSphere | A cube sphere. |
Hexasphere | Icosphere. |
IcoSphere | Icosphere. |
SquarePlane | A square. |
TetraSphere | Tetrasphere (Sphere from tetrahedron). |
TrianglePlane | A triangle. |