### Subdivided Shape Creation Source: https://docs.rs/hexasphere Example of how to initialize a subdivided shape using the IcoSphere implementation. ```APIDOC ## Rust Usage: Creating a Subdivided Shape ### Description Demonstrates how to instantiate an IcoSphere with a specific subdivision level and retrieve its vertex points and triangle indices. ### Request Example ```rust use hexasphere::shapes::IcoSphere; // Create a new sphere with 20 subdivisions let sphere = IcoSphere::new(20, |_| ()); let points = sphere.raw_points(); let indices = sphere.get_all_indices(); ``` ### Response - **points** (Vec) - The raw vertices generated by the subdivision. - **indices** (Vec) - The triangle indices representing the subdivided surface. ``` -------------------------------- ### CubeBase: Initial Points Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Returns the vertices for all main triangles of the CubeBase shape before any subdivision occurs. Refer to the crate's source file for examples. ```rust fn initial_points(&self) -> Vec; ``` -------------------------------- ### Square Edges Example Source: https://docs.rs/hexasphere/18.0.0/hexasphere/trait.BaseShape.html Illustrates the concept of edges for a square shape, where there are 4 unique edges connecting the vertices. ```text a - 0 - b | / | 3 4 1 | / | d - 2 - c ``` -------------------------------- ### Implementing BaseShape for FlatIcosahedron Source: https://docs.rs/hexasphere/18.0.0/hexasphere/trait.BaseShape.html Example of implementing the BaseShape trait to use linear interpolation instead of spherical. ```APIDOC ## Example Implementation: FlatIcosahedron ```rust use hexasphere::{Triangle, shapes::IcoSphereBase}; use glam::Vec3A; // Uses linear interpolation instead of spherical. struct FlatIcosahedron; impl BaseShape for FlatIcosahedron { // Keep the initial parameters. fn initial_points(&self) -> Vec { IcoSphereBase.initial_points() } fn triangles(&self) -> Box<[Triangle]> { IcoSphereBase.triangles() } const EDGES: usize = IcoSphereBase::EDGES; // Swap out what you'd like to change. fn interpolate(&self, a: Vec3A, b: Vec3A, p: f32) -> Vec3A { hexasphere::interpolation::lerp(a, b, p) } fn interpolate_half(&self, a: Vec3A, b: Vec3A) -> Vec3A { hexasphere::interpolation::lerp_half(a, b) } fn interpolate_multiple(&self, a: Vec3A, b: Vec3A, indices: &[u32], points: &mut [Vec3A]) { hexasphere::interpolation::lerp_multiple(a, b, indices, points); } } ``` ``` -------------------------------- ### GET /api/hexasphere/main_triangles Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Retrieves the base triangles used internally by the library. ```APIDOC ## GET /api/hexasphere/main_triangles ### Description Returns the base triangles used by the library internally. This typically won’t be useful to most people, except for when you want to know how many base triangles the shape had originally. ### Method GET ### Endpoint /api/hexasphere/main_triangles ### Response #### Success Response (200) - **triangles** (&[Triangle]) - A slice of the base triangles. ``` -------------------------------- ### GET /api/hexasphere/indices_per_main_triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Calculates the number of indices each main triangle will add to the vertex buffer. ```APIDOC ## GET /api/hexasphere/indices_per_main_triangle ### Description Calculate the number of indices which each main triangle will add to the vertex buffer. ### Method GET ### Endpoint /api/hexasphere/indices_per_main_triangle ### Response #### Success Response (200) - **count** (usize) - The number of indices per main triangle. Equation: `(subdivisions + 1)²`. ``` -------------------------------- ### Define Custom Shape Geometry and Interpolation with BaseShape Source: https://docs.rs/hexasphere/18.0.0/hexasphere/trait.BaseShape.html Implement the BaseShape trait to define a custom shape's geometry and interpolation. This example shows how to create a FlatIcosahedron by reusing IcoSphereBase's geometry and substituting linear interpolation. ```rust use hexasphere::{Triangle, shapes::IcoSphereBase}; use glam::Vec3A; // Uses linear interpolation instead of spherical. struct FlatIcosahedron; impl BaseShape for FlatIcosahedron { // Keep the initial parameters. fn initial_points(&self) -> Vec { IcoSphereBase.initial_points() } fn triangles(&self) -> Box<[Triangle]> { IcoSphereBase.triangles() } const EDGES: usize = IcoSphereBase::EDGES; // Swap out what you'd like to change. fn interpolate(&self, a: Vec3A, b: Vec3A, p: f32) -> Vec3A { hexasphere::interpolation::lerp(a, b, p) } fn interpolate_half(&self, a: Vec3A, b: Vec3A) -> Vec3A { hexasphere::interpolation::lerp_half(a, b) } fn interpolate_multiple(&self, a: Vec3A, b: Vec3A, indices: &[u32], points: &mut [Vec3A]) { hexasphere::interpolation::lerp_multiple(a, b, indices, points); } } ``` -------------------------------- ### GET /api/hexasphere/main_triangles Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Retrieves the base triangles used internally by the library. This is typically useful for understanding the original number of base triangles. ```APIDOC ## GET /api/hexasphere/main_triangles ### Description Returns the base triangles used by the library internally. This typically won’t be useful to most people, except for when you want to know how many base triangles the shape had originally. ### Method GET ### Endpoint /api/hexasphere/main_triangles ### Response #### Success Response (200) - **main_triangles** ([Triangle]) - A slice of the base triangles. ``` -------------------------------- ### Get All Triangle Indices Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Retrieves all indices for the triangles forming the subdivided shape. Indices refer to `raw_data` or `raw_points`. ```rust pub fn get_all_indices(&self) -> Vec ``` -------------------------------- ### Get Main Triangles - Hexasphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Returns a slice of the base triangles used internally by the library. This is primarily useful for determining the original number of base triangles. ```rust pub fn main_triangles(&self) -> &[Triangle] ``` -------------------------------- ### GET /api/hexasphere/indices_per_main_triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Calculates the number of indices each main triangle will add to the vertex buffer. The equation is (subdivisions + 1)². ```APIDOC ## GET /api/hexasphere/indices_per_main_triangle ### Description Calculate the number of indices which each main triangle will add to the vertex buffer. ##### §Equation ``` (subdivisions + 1)² ``` ### Method GET ### Endpoint /api/hexasphere/indices_per_main_triangle ### Response #### Success Response (200) - **indices_per_main_triangle** (usize) - The number of indices per main triangle. ``` -------------------------------- ### Get Major Edge Line Indices (Deprecated) Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TetraSphere.html Deprecated method for appending indices for the wireframe of a subdivided main triangle edge. Use `get_major_edges_line_indices` instead. ```rust pub fn get_major_edge_line_indices( &self, edge: usize, buffer: &mut Vec, delta: usize, ) ``` -------------------------------- ### Get Line Indices for CubeSphere Wireframe Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.CubeSphere.html Appends indices for the wireframe of a specified main triangle's subdivided form to a buffer. Useful for rendering wireframes. ```rust pub fn get_line_indices( &self, buffer: &mut Vec, triangle: usize, delta: usize, breaks: impl FnMut(&mut Vec), ) ``` ```rust pub fn get_major_edge_line_indices( &self, edge: usize, buffer: &mut Vec, delta: usize, ) ``` ```rust pub fn get_major_edges_line_indices( &self, buffer: &mut Vec, delta: u32, breaks: impl FnMut(&mut Vec), ) ``` -------------------------------- ### Get Indices for CubeSphere Triangles Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.CubeSphere.html Appends indices for a specific main triangle's subdivided form to a buffer. Indices refer to positions in raw_data or raw_points. ```rust pub fn get_indices(&self, triangle: usize, buffer: &mut Vec) ``` ```rust pub fn get_all_indices(&self) -> Vec ``` -------------------------------- ### Get Wireframe Indices for Base Shape Edges Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Appends indices for the wireframe of the base shape's main triangle edges to a buffer. Excludes edges created by subdivision. ```rust pub fn get_major_edges_line_indices( &self, buffer: &mut Vec, delta: u32, breaks: impl FnMut(&mut Vec), ) ``` -------------------------------- ### Get Wireframe Indices for a Specific Main Triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Appends indices for the wireframe of a specific main triangle's subdivided form to a buffer. See `get_all_line_indices` for format details. ```rust pub fn get_line_indices( &self, buffer: &mut Vec, triangle: usize, delta: usize, breaks: impl FnMut(&mut Vec), ) ``` -------------------------------- ### Create and iterate over an IcoSphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/index.html Demonstrates initializing an IcoSphere with 20 subdivisions and iterating over its vertices and triangle indices. ```rust 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], ); } ``` -------------------------------- ### CubeBase: Clone To Uninit (Nightly) Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html A nightly-only experimental API that implements `CloneToUninit`. It performs copy-assignment from `self` to a raw pointer `dest`. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8); ``` -------------------------------- ### GET /api/hexasphere/linear_distance Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Calculates the linear distance between two points on the shape. ```APIDOC ## GET /api/hexasphere/linear_distance ### Description Linear distance between two points on this shape. ### Method GET ### Endpoint /api/hexasphere/linear_distance ### Parameters #### Query Parameters - **p1** (u32) - Required - The index of the first point. - **p2** (u32) - Required - The index of the second point. - **radius** (f32) - Required - The radius of the shape. ### Response #### Success Response (200) - **distance** (f32) - The linear distance between the two points. ``` -------------------------------- ### GET /api/hexasphere/subdivisions Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Retrieves the number of subdivisions applied when this shape was created. ```APIDOC ## GET /api/hexasphere/subdivisions ### Description Returns the number of subdivisions applied when this shape was created. ### Method GET ### Endpoint /api/hexasphere/subdivisions ### Response #### Success Response (200) - **subdivisions** (usize) - The number of subdivisions. ``` -------------------------------- ### Get Subdivisions Count - Hexasphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Returns the number of subdivisions applied when this shape was created. ```rust pub fn subdivisions(&self) -> usize ``` -------------------------------- ### CubeSphere Initialization Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.CubeSphere.html Methods for creating a new CubeSphere instance with specific subdivision levels and vertex generators. ```APIDOC ## new ### Description Creates the base shape from S and subdivides it. ### Method Constructor ### Parameters #### Request Body - **subdivisions** (usize) - Required - The number of auxiliary points created along the edges. - **generator** (impl FnMut(Vec3A) -> T) - Required - A function run for each vertex once subdivisions are applied. ## new_custom_shape ### Description Creates the base shape from S and subdivides it using a custom shape implementation. ### Method Constructor ### Parameters #### Request Body - **subdivisions** (usize) - Required - The number of auxiliary points created along the edges. - **generator** (impl FnMut(Vec3A) -> T) - Required - A function run for each vertex once subdivisions are applied. - **shape** (S) - Required - The base shape implementation. ``` -------------------------------- ### SquarePlane Initialization and Subdivision Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Methods for creating a new SquarePlane instance and managing its subdivision levels. ```APIDOC ## new ### Description Creates the base shape from S and subdivides it. ### Method Static Constructor ### Parameters #### Request Body - **subdivisions** (usize) - Required - Number of auxiliary points created along edges. - **generator** (impl FnMut(Vec3A) -> T) - Required - Function to generate vertex data. ## subdivide ### Description Increases the current subdivision count by a specified amount. ### Method Instance Method ### Parameters #### Request Body - **amount** (usize) - Required - The amount to increase the subdivision count by. ``` -------------------------------- ### GET /api/hexasphere/raw_data Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Retrieves a slice of the custom data for each vertex created by the generator function. ```APIDOC ## GET /api/hexasphere/raw_data ### Description Returns the custom data for each vertex created by the generator function. The length of this slice is equal to the number of vertices in the subdivided shape. ### Method GET ### Endpoint /api/hexasphere/raw_data ### Response #### Success Response (200) - **data** (&[T]) - A slice of custom data for each vertex. ``` -------------------------------- ### TrianglePlane Initialization Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Methods for creating a new TrianglePlane instance with specific subdivision levels. ```APIDOC ## TrianglePlane::new ### Description Creates the base shape and subdivides it using a generator function. ### Parameters - **subdivisions** (usize) - Required - Number of auxiliary points created along edges. - **generator** (impl FnMut(Vec3A) -> T) - Required - Function to generate vertex data. ### Response - **Self** (TrianglePlane) - The initialized subdivided shape. ``` -------------------------------- ### CubeBase: Clone From Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `clone_from` method for `CubeBase`, enabling efficient copy-assignment from another `CubeBase` instance. ```rust fn clone_from(&mut self, source: &Self); ``` -------------------------------- ### GET /api/hexasphere/vertices_per_main_triangle_unique Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Calculates the number of vertices within each main triangle, excluding shared vertices. ```APIDOC ## GET /api/hexasphere/vertices_per_main_triangle_unique ### Description Calculate the number of vertices contained within each main triangle excluding the ones that are shared with other main triangles. ### Method GET ### Endpoint /api/hexasphere/vertices_per_main_triangle_unique ### Response #### Success Response (200) - **count** (usize) - The number of unique vertices per main triangle. Equation: `{ subdivisions < 2 : 0, subdivisions >= 2 : (subdivisions - 1) * subdivisions / 2 }`. ``` -------------------------------- ### GET /api/hexasphere/shared_vertices Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Calculates the total number of shared vertices along the edges and at the vertices of the main triangles. ```APIDOC ## GET /api/hexasphere/shared_vertices ### Description Calculate the number of vertices along the edges of the main triangles and the vertices of the main triangles. ### Method GET ### Endpoint /api/hexasphere/shared_vertices ### Response #### Success Response (200) - **count** (usize) - The total number of shared vertices. Equation: `subdivisions * EDGES + INITIAL_POINTS`. ``` -------------------------------- ### Blanket Implementations for TriangleBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TriangleBase.html Details on blanket trait implementations applied to TriangleBase, such as Any, Borrow, CloneToUninit, From, Into, ToOwned, TryFrom, and TryInto. ```APIDOC ## Blanket Implementations ### impl Any for T #### fn type_id(&self) -> TypeId ### impl Borrow for T #### fn borrow(&self) -> &T ### impl BorrowMut for T #### fn borrow_mut(&mut self) -> &mut T ### impl CloneToUninit for T #### unsafe fn clone_to_uninit(&self, dest: *mut u8) ### impl From for T #### fn from(t: T) -> T ### impl Into for T #### fn into(self) -> U ### impl ToOwned for T #### type Owned = T #### fn to_owned(&self) -> T #### fn clone_into(&self, target: &mut T) ### impl TryFrom for T #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> ### impl TryInto for T #### type Error = >::Error #### fn try_into(self) -> Result>::Error> ``` -------------------------------- ### GET /api/hexasphere/vertices_per_main_triangle_shared Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Calculates the number of vertices contained within each main triangle, including shared vertices. ```APIDOC ## GET /api/hexasphere/vertices_per_main_triangle_shared ### Description Calculate the number of vertices contained within each main triangle including the vertices which are shared with another main triangle. ### Method GET ### Endpoint /api/hexasphere/vertices_per_main_triangle_shared ### Response #### Success Response (200) - **count** (usize) - The number of shared vertices per main triangle. Equation: `(subdivisions + 1) * (subdivisions + 2) / 2`. ``` -------------------------------- ### TetraSphere Implementations Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TetraSphere.html Provides methods for creating, subdividing, and retrieving data from a TetraSphere. ```APIDOC ## Implementations for Subdivided where S: BaseShape ### `new` Method #### Description Creates the base shape from `S` and subdivides it. This is equivalent to `Subdivided::new_custom_shape(subdivisions, generator, S::default())` and is convenient when `S` implements `Default`. #### Signature ```rust pub fn new(subdivisions: usize, generator: impl FnMut(Vec3A) -> T) -> Self ``` ### `new_custom_shape` Method #### Description Creates the base shape from `S` and subdivides it. - `subdivisions` specifies the number of auxiliary points that will be created along the edges the vertices of the base shape. For example, if `subdivisions` is 0, then the base shape is unaltered; if `subdivisions` is 3, then each edge of the base shape will have 3 added points, forming 4 triangle edges. - `generator` is a function run for each vertex once all the subdivisions are applied, and its values are stored in an internal `Vec`, accessible from `Self::raw_data()`. #### Signature ```rust pub fn new_custom_shape( subdivisions: usize, generator: impl FnMut(Vec3A) -> T, shape: S, ) -> Self ``` ### `subdivide` Method #### Description Increases the current subdivision count by `amount`. After calling this, you must call `Self::calculate_values()` to compute new vertex data. #### Signature ```rust pub fn subdivide(&mut self, amount: usize) ``` ### `calculate_values` Method #### Description Recalculate data after `Self::subdivide()`. #### Signature ```rust pub fn calculate_values(&mut self, generator: impl FnMut(Vec3A) -> T) ``` ### `raw_points` Method #### Description The vertex positions created by the subdivision process. #### Signature ```rust pub fn raw_points(&self) -> &[Vec3A] ``` ### `get_indices` Method #### Description Appends the indices for the subdivided form of the specified main triangle into `buffer`. The specified `triangle` is a main triangle on the base shape. The range of this should be limited to the number of triangles in the base shape. Alternatively, use `Self::get_all_indices` to get all the indices. Each element put into `buffer` is an index into `Self::raw_data` or `Self::raw_points` specifying the position of a triangle vertex. The first three elements specify the three vertices of a triangle to be drawn, and the next three elements specify another triangle, and so on. #### Signature ```rust pub fn get_indices(&self, triangle: usize, buffer: &mut Vec) ``` ### `get_all_indices` Method #### Description Gets the indices for the triangles making up the subdivided shape. Each element of the returned `Vec` is an index into `Self::raw_data` or `Self::raw_points` specifying the position of a triangle vertex. The first three elements specify the three vertices of a triangle to be drawn, and the next three elements specify another triangle, and so on. Together, these triangles cover the entire surface of the shape. #### Signature ```rust pub fn get_all_indices(&self) -> Vec ``` ### `get_line_indices` Method #### Description Appends indices for the wireframe of the subdivided form of the specified main triangle to `buffer`. This is equivalent to `Self::get_all_line_indices` except that it selects a single main triangle from the base shape. See its documentation for the format of the result, and how to use `delta` and `breaks`. #### Signature ```rust pub fn get_line_indices( &self, buffer: &mut Vec, triangle: usize, delta: usize, breaks: impl FnMut(&mut Vec), ) ``` ### `get_major_edge_line_indices` Method (Deprecated) #### Description Deprecated: Flawed. Use `get_major_edges_line_indices()` instead. Appends indices for the wireframe of the subdivided form of the specified main triangle edge to `buffer`. The valid range of `edge` is `0..(S::EDGES)`. See `Self::get_line_indices` for more on `delta`. #### Signature ```rust pub fn get_major_edge_line_indices( &self, edge: usize, buffer: &mut Vec, delta: usize, ) ``` ### `get_major_edges_line_indices` Method #### Description Appends indices for the wireframe of the subdivided form of the base shape’s main triangles’ edges to `buffer`. Compared to `Self::get_all_line_indices`, this does not return edges of any of the triangles which were created by subdivision — only edges of the original triangles. See that method’s documentation for how to use `delta` and `breaks`. #### Signature ```rust pub fn get_major_edges_line_indices( &self, buffer: &mut Vec, delta: u32, breaks: impl FnMut(&mut Vec), ) ``` ``` -------------------------------- ### Get Raw Points of CubeSphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.CubeSphere.html Retrieves a slice containing the vertex positions generated by the subdivision process. ```rust pub fn raw_points(&self) -> &[Vec3A] ``` -------------------------------- ### Triangle::new Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Triangle.html Creates a new Triangle instance with specified vertex and edge indices. ```APIDOC ## Triangle::new ### Description Creates a new `Triangle` given the necessary vertex and edge data. The vertices `a`, `b`, and `c` must be provided in a counter-clockwise winding order. ### Parameters - **a** (u32) - Required - Index into BaseShape::initial_points() for the first vertex. - **b** (u32) - Required - Index into BaseShape::initial_points() for the second vertex. - **c** (u32) - Required - Index into BaseShape::initial_points() for the third vertex. - **ab_edge** (usize) - Required - Index of the edge bordering a and b. - **bc_edge** (usize) - Required - Index of the edge bordering b and c. - **ca_edge** (usize) - Required - Index of the edge bordering c and a. ### Response - **Triangle** (struct) - A new instance of the Triangle struct. ``` -------------------------------- ### Implementations of BaseShape Source: https://docs.rs/hexasphere/18.0.0/hexasphere/trait.BaseShape.html Lists the available implementations of the BaseShape trait for different geometric primitives. ```APIDOC ## Implementors ### impl BaseShape for CubeBase #### const EDGES: usize = consts::cube::EDGES ### impl BaseShape for IcoSphereBase #### const EDGES: usize = consts::icosphere::EDGES ### impl BaseShape for NormIcoSphereBase #### const EDGES: usize = consts::icosphere::EDGES ### impl BaseShape for SquareBase #### const EDGES: usize = consts::square::EDGES ### impl BaseShape for TetraSphereBase #### const EDGES: usize = consts::tetrasphere::EDGES ``` -------------------------------- ### TryFrom and TryInto Traits Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Traits for fallible conversions between types. ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs a fallible conversion from type U to type T. ## fn try_into(self) -> Result>::Error> ### Description Performs a fallible conversion into type U. ``` -------------------------------- ### Auto Trait Implementations for TriangleBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TriangleBase.html List of auto trait implementations for TriangleBase, including Send, Sync, Unpin, Freeze, RefUnwindSafe, and UnwindSafe. ```APIDOC ## Auto Trait Implementations ### impl Freeze for TriangleBase ### impl RefUnwindSafe for TriangleBase ### impl Send for TriangleBase ### impl Sync for TriangleBase ### impl Unpin for TriangleBase ### impl UnwindSafe for TriangleBase ``` -------------------------------- ### GET /api/hexasphere/shared_vertices Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Calculates the number of shared vertices along the edges and at the vertices of the main triangles. The equation is subdivisions * EDGES + INITIAL_POINTS. ```APIDOC ## GET /api/hexasphere/shared_vertices ### Description Calculate the number of vertices along the edges of the main triangles and the vertices of the main triangles. ##### §Equation ``` subdivisions * EDGES + INITIAL_POINTS ``` ### Method GET ### Endpoint /api/hexasphere/shared_vertices ### Response #### Success Response (200) - **shared_vertices** (usize) - The total number of shared vertices. ``` -------------------------------- ### CubeBase: From Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `From` trait for `CubeBase`, allowing conversion from a `T` to a `CubeBase` where `T` is the same type. This effectively returns the argument unchanged. ```rust fn from(t: T) -> T; ``` -------------------------------- ### GET /api/hexasphere/vertices_per_main_triangle_unique Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Calculates the number of vertices within each main triangle, excluding shared vertices. The equation depends on the number of subdivisions. ```APIDOC ## GET /api/hexasphere/vertices_per_main_triangle_unique ### Description Calculate the number of vertices contained within each main triangle excluding the ones that are shared with other main triangles. ##### §Equation ``` { subdivisions < 2 : 0 { subdivisions >= 2 : (subdivisions - 1) * subdivisions / 2 } ``` ### Method GET ### Endpoint /api/hexasphere/vertices_per_main_triangle_unique ### Response #### Success Response (200) - **vertices_per_main_triangle_unique** (usize) - The number of unique vertices per main triangle. ``` -------------------------------- ### Function normalized_lerp_multiple Source: https://docs.rs/hexasphere/18.0.0/hexasphere/interpolation/fn.normalized_lerp_multiple.html This function is provided as a plugin for users who need it. It implements essentially the same algorithm as `BaseShape` without requiring reimplementation. ```APIDOC ## Function normalized_lerp_multiple ### Description This function is provided as a plug in for people who need it, but this implements essentially the same algorithm as `BaseShape` would without ever being reimplemented. ### Signature ```rust pub fn normalized_lerp_multiple( a: Vec3A, b: Vec3A, indices: & [u32], points: &mut [Vec3A], ) ``` ### Parameters - **a** (Vec3A) - The starting point for interpolation. - **b** (Vec3A) - The ending point for interpolation. - **indices** (&[u32]) - A slice of unsigned 32-bit integers representing indices. - **points** (&mut [Vec3A]) - A mutable slice of Vec3A to store the interpolated points. ``` -------------------------------- ### Nightly-Only clone_to_uninit Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Triangle.html An experimental, nightly-only function to perform copy-assignment to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### GET /api/hexasphere/line_indices Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.NormIcoSphere.html Retrieves a vector of indices for the wireframe of the subdivided mesh. These indices define line strips, with breaks handled by a provided function. ```APIDOC ## GET /api/hexasphere/line_indices ### Description Returns a vector of indices for the wireframe of the subdivided mesh. Each element in the returned `Vec` is an index into `Self::raw_data` or `Self::raw_points` specifying the position of a triangle vertex. The indices are formatted as “line strips”; that is, each vertex should be connected to the previous by a line, except where a break is specified. The `breaks` function is run every time there is a necessary break in the line strip. Use this to, for example, swap out the buffer using `std::mem::take`, or push a special break-marking index into the buffer. `delta` is added to all of the indices pushed into the buffer, and is generally intended to be used together with `breaks` to allow a marker index at zero. This marker index might be used to refer to a vertex with position set to NaN, or parsed in some other way by the graphics API the indices are fed to. ### Method GET ### Endpoint /api/hexasphere/line_indices ### Parameters #### Query Parameters - **delta** (usize) - Required - The value to add to all indices. - **breaks** (function) - Required - A function to handle breaks in the line strip. ### Response #### Success Response (200) - **indices** (Vec) - A vector of indices for the wireframe. ``` -------------------------------- ### Clone Triangle Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Triangle.html Provides methods for cloning a `Triangle` instance, allowing for duplication and copy-assignment. ```rust fn clone(&self) -> Triangle ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### GET /api/hexasphere/raw_data Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Retrieves the custom data for each vertex created by the generator function. The length of this slice is equal to the number of vertices in the subdivided shape. ```APIDOC ## GET /api/hexasphere/raw_data ### Description Returns the custom data for each vertex created by the generator function. The length of this slice is equal to the number of vertices in the subdivided shape. ### Method GET ### Endpoint /api/hexasphere/raw_data ### Response #### Success Response (200) - **raw_data** ([T]) - A slice of custom data for each vertex. ``` -------------------------------- ### Hexasphere Structs Source: https://docs.rs/hexasphere/18.0.0/hexasphere/all.html This section lists the available structs within the hexasphere crate. ```APIDOC ## Structs ### Subdivided Represents a subdivided shape. ### Triangle Represents a triangle shape. ### shapes::CubeBase Base structure for cube-related shapes. ### shapes::IcoSphereBase Base structure for icosphere-related shapes. ### shapes::NormIcoSphereBase Base structure for normalized icosphere-related shapes. ### shapes::SquareBase Base structure for square-related shapes. ### shapes::TetraSphereBase Base structure for tetrasphere-related shapes. ### shapes::TriangleBase Base structure for triangle-related shapes. ``` -------------------------------- ### Get Wireframe Indices for Major Edges (Deprecated) Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Deprecated: Appends indices for the wireframe of a specific main triangle edge. Use `get_major_edges_line_indices` instead. ```rust pub fn get_major_edge_line_indices( &self, edge: usize, buffer: &mut Vec, delta: usize, ) ``` -------------------------------- ### Clone Trait Implementation for TriangleBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TriangleBase.html Implementation of the Clone trait for TriangleBase, allowing instances to be duplicated. ```APIDOC ### impl Clone for TriangleBase #### fn clone(&self) -> TriangleBase Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### Blanket Implementations for TetraSphereBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TetraSphereBase.html Details the blanket implementations provided for TetraSphereBase, which are generic implementations applicable to many types. ```APIDOC ## Blanket Implementations ### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl CloneToUninit for T where T: Clone, #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T where U: From, #### fn into(self) -> U Calls `U::from(self)`. ### impl ToOwned for T where T: Clone, #### type Owned = T #### fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. #### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. ### impl TryFrom for T where U: Into, #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T where U: TryFrom, #### type Error = >::Error #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### GET /api/hexasphere/vertices_per_main_triangle_shared Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.SquarePlane.html Calculates the number of vertices contained within each main triangle, including shared vertices. The equation is (subdivisions + 1) * (subdivisions + 2) / 2. ```APIDOC ## GET /api/hexasphere/vertices_per_main_triangle_shared ### Description Calculate the number of vertices contained within each main triangle including the vertices which are shared with another main triangle. ##### §Equation ``` (subdivisions + 1) * (subdivisions + 2) / 2 ``` ### Method GET ### Endpoint /api/hexasphere/vertices_per_main_triangle_shared ### Response #### Success Response (200) - **vertices_per_main_triangle_shared** (usize) - The number of shared vertices per main triangle. ``` -------------------------------- ### CubeBase: TryInto Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `TryInto` trait for `CubeBase`, allowing fallible conversion from `CubeBase` into another type `U` if `U` implements `TryFrom`. ```rust type Error = >::Error; ``` ```rust fn try_into(self) -> Result>::Error>; ``` -------------------------------- ### CubeBase: Debug Formatting Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `Debug` trait for `CubeBase`, allowing instances to be formatted for debugging purposes using a provided `Formatter`. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result; ``` -------------------------------- ### Get Indices for a Specific Main Triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TrianglePlane.html Appends indices for a specific main triangle's subdivided form to a buffer. Indices refer to `raw_data` or `raw_points`. ```rust pub fn get_indices(&self, triangle: usize, buffer: &mut Vec) ``` -------------------------------- ### Implement geometric_slerp Source: https://docs.rs/hexasphere/18.0.0/hexasphere/interpolation/fn.geometric_slerp.html Use this function for spherical interpolation. Ensure 'a' and 'b' are normalized for normalized results. ```rust pub fn geometric_slerp(a: Vec3A, b: Vec3A, p: f32) -> Vec3A ``` -------------------------------- ### Create New Triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Triangle.html Constructs a new `Triangle` instance. Ensure vertex indices (`a`, `b`, `c`) are in counter-clockwise order and edge indices correctly reference shared edges. ```rust pub const fn new( a: u32, b: u32, c: u32, ab_edge: usize, bc_edge: usize, ca_edge: usize, ) -> Self ``` -------------------------------- ### CubeBase: Clone Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `Clone` trait for `CubeBase`, allowing instances to be duplicated. This is essential for creating copies of the shape. ```rust fn clone(&self) -> CubeBase; ``` -------------------------------- ### Get Raw Vertex Data - Hexasphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Returns the custom data for each vertex created by the generator function. The length of this slice equals the number of vertices in the subdivided shape. ```rust pub fn raw_data(&self) -> &[T] ``` -------------------------------- ### CubeBase: TryFrom Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `TryFrom` trait for `CubeBase`, allowing fallible conversion from a type `U` into `CubeBase` if `U` implements `Into`. The `Error` type is `Infallible`. ```rust type Error = Infallible; ``` ```rust fn try_from(value: U) -> Result>::Error>; ``` -------------------------------- ### Get Major Edges Line Indices Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TetraSphere.html Appends indices for the wireframe of the base shape's main triangle edges to a buffer. Excludes edges created by subdivision. ```rust pub fn get_major_edges_line_indices( &self, buffer: &mut Vec, delta: u32, breaks: impl FnMut(&mut Vec), ) ``` -------------------------------- ### Perform Linear Interpolation with lerp Source: https://docs.rs/hexasphere/18.0.0/hexasphere/interpolation/fn.lerp.html Use this function for straightforward linear interpolation between two 3D points. Ensure that the input points are of type Vec3A and the interpolation factor is a float. ```rust pub fn lerp(a: Vec3A, b: Vec3A, p: f32) -> Vec3A ``` -------------------------------- ### Get Line Indices for a Specific Triangle Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.TetraSphere.html Appends indices for the wireframe of a specific main triangle's subdivided form to a buffer. Use `delta` and `breaks` for customization. ```rust pub fn get_line_indices( &self, buffer: &mut Vec, triangle: usize, delta: usize, breaks: impl FnMut(&mut Vec), ) ``` -------------------------------- ### Struct CubeBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Details regarding the CubeBase struct and its implementation of the BaseShape trait. ```APIDOC ## Struct CubeBase ### Description Implements a cube as the base shape for sphere generation. It consists of 8 vertices, 12 faces, and 18 edges, with a half-diagonal of 1.0. ### Trait Implementations - **BaseShape** - **EDGES** (usize): Number of unique edges defined in the contents of triangles(). - **initial_points()**: Returns the vertices for all main triangles of the shape. - **triangles()**: Returns the main triangles for the shape before subdivision. - **interpolate(a, b, p)**: Basic function used for interpolation between two points. - **interpolate_half(a, b)**: Optimized interpolation for the midpoint (p=0.5). - **interpolate_multiple(a, b, indices, points)**: Optimized interpolation for multiple points sharing the same endpoints. ``` -------------------------------- ### CubeBase: Interpolate Half Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements an optimization for interpolating between two points when the factor 'p' is exactly 0.5. Defaults to calling the general `interpolate` function if no specific optimization is available. ```rust fn interpolate_half(&self, a: Vec3A, b: Vec3A) -> Vec3A; ``` -------------------------------- ### Get Mutable Raw Vertex Data - Hexasphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Returns mutable access to the custom data created by the generator function. The length of this slice equals the number of vertices in the subdivided shape. ```rust pub fn raw_data_mut(&mut self) -> &mut [T] ``` -------------------------------- ### CubeBase: Main Triangles Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Returns the main triangles that constitute the CubeBase shape before subdivision. This is a core component for defining the shape's geometry. ```rust fn triangles(&self) -> Box<[Triangle]>; ``` -------------------------------- ### CubeBase: Interpolate Multiple Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Provides an optimization for interpolating between two points ('a' and 'b') when the interpolation factor 'p' varies but 'a' and 'b' remain constant across multiple calls. Updates the provided `points` slice. ```rust fn interpolate_multiple( &self, a: Vec3A, b: Vec3A, indices: &[u32], points: &mut [Vec3A], ); ``` -------------------------------- ### TriangleBase Struct Definition Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TriangleBase.html The basic structure definition for TriangleBase. ```rust pub struct TriangleBase; ``` -------------------------------- ### geometric_slerp_multiple Function Source: https://docs.rs/hexasphere/18.0.0/hexasphere/interpolation/fn.geometric_slerp_multiple.html The `geometric_slerp_multiple` function is an optimization for calculating varying values of `p` for the same start and end points when multiple points require interpolation. It is intended for use within `BaseShape::interpolate_multiple`. For normalized results, ensure that both `a` and `b` are normalized. ```APIDOC ## geometric_slerp_multiple ### Description This is an optimization for the case where multiple points require the calculation of varying values of `p` for the same start and end points. See the intended use in `BaseShape::interpolate_multiple`. Note: `a` and `b` should both be normalized for normalized results. ### Function Signature ```rust pub fn geometric_slerp_multiple( a: Vec3A, b: Vec3A, indices: &[u32], points: &mut [Vec3A], ) ``` ### Parameters - **a** (Vec3A) - The starting point for interpolation. Should be normalized for normalized results. - **b** (Vec3A) - The ending point for interpolation. Should be normalized for normalized results. - **indices** (&[u32]) - A slice of unsigned 32-bit integers representing the indices of the points to be interpolated. - **points** (&mut [Vec3A]) - A mutable slice of Vec3A where the interpolated points will be stored. ### Notes - This function is an optimization for scenarios involving multiple interpolations between the same `a` and `b`. - For accurate normalized results, the input vectors `a` and `b` must be normalized prior to calling this function. ``` -------------------------------- ### CubeBase: Into Implementation Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.CubeBase.html Implements the `Into` trait for `CubeBase`, allowing conversion from `CubeBase` to another type `U` if `U` implements `From`. ```rust fn into(self) -> U; ``` -------------------------------- ### Get All Line Indices - Hexasphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/struct.Subdivided.html Returns a vector of indices for the wireframe of the subdivided mesh. Indices specify vertices in `raw_data` or `raw_points`. The `breaks` function handles necessary breaks in line strips, and `delta` is added to indices, often used with a zero marker. ```rust pub fn get_all_line_indices( &self, delta: usize, breaks: impl FnMut(&mut Vec), ) -> Vec ``` -------------------------------- ### Create and Subdivide CubeSphere Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/type.CubeSphere.html Creates a new CubeSphere with a specified number of subdivisions and a generator function. The shape can be further subdivided. ```rust pub fn new(subdivisions: usize, generator: impl FnMut(Vec3A) -> T) -> Self where S: Default, ``` ```rust pub fn new_custom_shape( subdivisions: usize, generator: impl FnMut(Vec3A) -> T, shape: S, ) -> Self ``` ```rust pub fn subdivide(&mut self, amount: usize) ``` -------------------------------- ### BaseShape Trait Implementation for TriangleBase Source: https://docs.rs/hexasphere/18.0.0/hexasphere/shapes/struct.TriangleBase.html Implementation of the BaseShape trait for TriangleBase, providing methods for defining triangle properties, initial points, and interpolation. ```APIDOC ### impl BaseShape for TriangleBase #### const EDGES: usize = consts::triangle::EDGES Number of unique edges defined in the contents of `triangles()`. This number is 5 for a square for example. #### fn initial_points(&self) -> Vec The vertices for all main triangles of the shape. Check the source file for this crate and look for the constants module at the bottom for an example. #### fn triangles(&self) -> Box<[Triangle]> Main triangles for the shape; that is, the triangles which exist before subdivision. #### fn interpolate(&self, a: Vec3A, b: Vec3A, p: f32) -> Vec3A Basic function used for interpolation. When `p` is `0.0`, `a` is expected. When `p` is `1.0`, `b` is expected. There are three options already implemented in this crate. #### fn interpolate_half(&self, a: Vec3A, b: Vec3A) -> Vec3A If an optimization is available for the case where `p` is `0.5`, this function should implement it. This defaults to calling `interpolate(a, b, 0.5)` however. #### fn interpolate_multiple( &self, a: Vec3A, b: Vec3A, indices: &[u32], points: &mut [Vec3A], ) If an optimization is available for the case where `p` varies but `a` and `b` don’t, this function should implement it. ```