pub struct ZCurve {
pub part_count: usize,
pub order: u32,
}
Expand description
Z space-filling curve algorithm
The Z-curve uses space hashing to partition points. The points in the same part of a partition have the same Z-hash. This hash is computed by recursively constructing a N-dimensional region tree.
Example
use coupe::Partition as _;
use coupe::Point2D;
let points = [
Point2D::new(0., 0.),
Point2D::new(1., 1.),
Point2D::new(0., 10.),
Point2D::new(1., 9.),
Point2D::new(9., 1.),
Point2D::new(10., 0.),
Point2D::new(10., 10.),
Point2D::new(9., 9.),
];
let mut partition = [0; 8];
// generate a partition of 4 parts
coupe::ZCurve { part_count: 4, order: 5 }
.partition(&mut partition, &points)?;
assert_eq!(partition[0], partition[1]);
assert_eq!(partition[2], partition[3]);
assert_eq!(partition[4], partition[5]);
assert_eq!(partition[6], partition[7]);
Fields§
§part_count: usize
§order: u32
Trait Implementations§
source§impl<'a, const D: usize> Partition<&'a [Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>]> for ZCurvewhere
Const<D>: DimSub<Const<1>> + ToTypenum,
DefaultAllocator: Allocator<f64, Const<D>, Const<D>, Buffer = ArrayStorage<f64, D, D>> + Allocator<f64, DimDiff<Const<D>, Const<1>>>,
impl<'a, const D: usize> Partition<&'a [Matrix<f64, Const<D>, Const<1>, ArrayStorage<f64, D, 1>>]> for ZCurvewhere Const<D>: DimSub<Const<1>> + ToTypenum, DefaultAllocator: Allocator<f64, Const<D>, Const<D>, Buffer = ArrayStorage<f64, D, D>> + Allocator<f64, DimDiff<Const<D>, Const<1>>>,
§type Error = Infallible
type Error = Infallible
Error details, should the algorithm fail to run.
impl Copy for ZCurve
Auto Trait Implementations§
impl RefUnwindSafe for ZCurve
impl Send for ZCurve
impl Sync for ZCurve
impl Unpin for ZCurve
impl UnwindSafe for ZCurve
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.