[][src]Struct hilbert16::Curve

pub struct Curve { /* fields omitted */ }

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]

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]

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]

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]

impl PartialEq<Curve> for Curve[src]

impl PartialOrd<Curve> for Curve[src]

impl StructuralEq for Curve[src]

impl StructuralPartialEq for Curve[src]

Auto Trait Implementations

impl Send for Curve[src]

impl Sync for Curve[src]

impl Unpin for Curve[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.