[−][src]Struct hilbert16::Curve
A psuedo-Hilbert curve.
This type is optimized for O(1) queries of arbitrary points or distances without pre-calculating the curve.
Implementations
impl Curve
[src]
#[must_use]pub fn new(order: u8) -> Option<Self>
[src]
Generate an iteration of the Hilbert curve with the given order
.
The largest supported order is 15, which corresponds a square of 32768 by 32768 units.
Examples
use hilbert16::Curve; assert!(matches!(Curve::new(15), Some(_))); assert_eq!(Curve::new(16), None);
#[must_use]pub const fn order(self) -> u8
[src]
The Hilbert curve's order.
Examples
use hilbert16::Curve; let curve = Curve::new(2).unwrap(); assert_eq!(curve.order(), 2);
#[must_use]pub const fn side_len(self) -> u16
[src]
The side length of the Hilbert curve's enclosing square.
Examples
use hilbert16::Curve; let curve = Curve::new(2).unwrap(); assert_eq!(curve.side_len(), 4);
#[must_use]pub const fn num_pnts(self) -> u32
[src]
The number of points contained in the Hilbert curve.
Examples
use hilbert16::Curve; let curve = Curve::new(2).unwrap(); assert_eq!(curve.num_pnts(), 16);
#[must_use]pub fn point_at(self, d: u32) -> Option<Point>
[src]
Get the point corresponding to the given distance.
Examples
use hilbert16::{Curve, Point}; let curve = Curve::new(1).unwrap(); let p = curve.point_at(2).unwrap(); assert_eq!(p, Point { x: 1, y: 1 });
pub fn dist_at<P>(self, p: P) -> Option<u32> where
P: Into<Point>,
[src]
P: Into<Point>,
Get the distance corresponding to the given point.
Examples
use hilbert16::Curve; let curve = Curve::new(1).unwrap(); let dist = curve.dist_at((1u16, 1u16)).unwrap(); assert_eq!(dist, 2);
#[must_use]pub fn wrapping_point_at(self, d: u32) -> Point
[src]
Get the point corresponding to the given distance, wrapping back to (0, 0)
.
Examples
use hilbert16::{Curve, Point}; let curve = Curve::new(1).unwrap(); let pnt = curve.wrapping_point_at(6); assert_eq!(pnt, Point { x: 1, y: 1 });
pub fn wrapping_dist_at<P>(self, p: P) -> u32 where
P: Into<Point>,
[src]
P: Into<Point>,
Get the distance corresponding to the given point, wrapping back to 0
.
Examples
use hilbert16::Curve; let curve = Curve::new(1).unwrap(); let dist = curve.wrapping_dist_at((3u16, 1u16)); assert_eq!(dist, 2);
Trait Implementations
impl Clone for Curve
[src]
pub fn clone(&self) -> Curve
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Curve
[src]
impl Debug for Curve
[src]
impl Default for Curve
[src]
impl Eq for Curve
[src]
impl Ord for Curve
[src]
pub fn cmp(&self, other: &Curve) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Curve> for Curve
[src]
impl PartialOrd<Curve> for Curve
[src]
pub fn partial_cmp(&self, other: &Curve) -> Option<Ordering>
[src]
pub fn lt(&self, other: &Curve) -> bool
[src]
pub fn le(&self, other: &Curve) -> bool
[src]
pub fn gt(&self, other: &Curve) -> bool
[src]
pub fn ge(&self, other: &Curve) -> bool
[src]
impl StructuralEq for Curve
[src]
impl StructuralPartialEq for Curve
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,