pub struct RegularTernaryGrid { /* private fields */ }Expand description
A reusable view of the canonical regular ternary composition lattice.
The grid visits lattice coordinates in the exact order used by RegularTernaryScalarField: i increases first, then j, with k = subdivisions - i - j. Its iterators are lazy and do not allocate.
Example:
use ternary_contours::{LatticeCoordinate, RegularTernaryGrid};
let grid = RegularTernaryGrid::new(2)?;
let coordinates: Vec<_> = grid.lattice_coordinates().collect();
assert_eq!(coordinates[0], LatticeCoordinate { i: 0, j: 0, k: 2 });Implementations§
Source§impl RegularTernaryGrid
impl RegularTernaryGrid
Sourcepub fn new(subdivisions: usize) -> Result<RegularTernaryGrid, FieldError>
pub fn new(subdivisions: usize) -> Result<RegularTernaryGrid, FieldError>
Create a regular ternary lattice with subdivisions intervals per edge.
The subdivision count must be positive. Its vertex count is (n + 1) * (n + 2) / 2 and is checked for overflow.
Sourcepub const fn subdivisions(&self) -> usize
pub const fn subdivisions(&self) -> usize
Number of intervals on each binary edge.
Sourcepub const fn vertex_count(&self) -> usize
pub const fn vertex_count(&self) -> usize
Number of vertices in canonical scalar-field order.
Sourcepub fn lattice_coordinates(&self) -> impl ExactSizeIterator + Clone
pub fn lattice_coordinates(&self) -> impl ExactSizeIterator + Clone
Lazily iterate canonical integer lattice coordinates.
The iterator is exact-sized and yields i = 0..=n, j = 0..=n-i, and k = n-i-j.
Sourcepub fn compositions(&self) -> impl ExactSizeIterator + Clone
pub fn compositions(&self) -> impl ExactSizeIterator + Clone
Lazily iterate normalized semantic compositions in canonical field order.
Each item is [i/n, j/n, k/n] in A/B/C component order.
Example:
use ternary_contours::RegularTernaryGrid;
let grid = RegularTernaryGrid::new(2)?;
assert_eq!(grid.compositions().next(), Some([0.0, 0.0, 1.0]));Sourcepub fn indexed_compositions(&self) -> impl ExactSizeIterator + Clone
pub fn indexed_compositions(&self) -> impl ExactSizeIterator + Clone
Lazily iterate scalar-field vertex identifiers and normalized compositions.
Every identifier matches the canonical order expected by RegularTernaryScalarField::new.
Trait Implementations§
Source§impl Clone for RegularTernaryGrid
impl Clone for RegularTernaryGrid
Source§fn clone(&self) -> RegularTernaryGrid
fn clone(&self) -> RegularTernaryGrid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more