Struct pasture_core::math::MortonIndex64[][src]

pub struct MortonIndex64 { /* fields omitted */ }

64-bit 3D Morton index

Implementations

impl MortonIndex64[src]

pub const LEVELS: usize[src]

pub fn from_raw(index: u64) -> Self[src]

Creates a MortonIndex64 from the given raw index

Example:

let morton_index = MortonIndex64::from_raw(1234);

pub fn from_octants(octants: &[Octant]) -> Self[src]

Creates a MortonIndex64 that encodes the given octree octants. The order of the octant numbering is unspecified, i.e. there is no assumption made which octant in 3D space has index 0, 1, etc. Octants are encoded little-endian, i.e. the first octant is encoded in the most significant bits of the Morton index. octants may contain at most MortonIndex64::LEVELS entries. If it contains less than MortonIndex64::LEVELS entries, the remaining octants will be zero.

Example:

// Create a Morton index for the octants 1->2->4 (octant 4 of octant 2 of octant 1 of the root node)
let morton_index = MortonIndex64::from_octants(&[Octant::ONE, Octant::TWO, Octant::FOUR]);
assert_eq!(Some(Octant::ONE), morton_index.get_octant_at_level(1));
assert_eq!(Some(Octant::TWO), morton_index.get_octant_at_level(2));
assert_eq!(Some(Octant::FOUR), morton_index.get_octant_at_level(3));

pub fn from_point_in_bounds(point: &Point3<f64>, bounds: &AABB<f64>) -> Self[src]

Computes a MortonIndex64 for the given point within bounds. Octant order is ZYX little-endian (MSB encodes Z, LSB encodes X)

pub fn index(&self) -> u64[src]

Returns the raw value of the associated MortonIndex64

let morton_index = MortonIndex64::from_raw(1234);
assert_eq!(1234, morton_index.index());

pub fn set_octant_at_level(&mut self, level: u8, octant: Octant)[src]

Sets the octant index at the specified level to octant. level must be in [1;MortonIndex64::LEVELS]. This may seem surprising, however in an octree level 0 represents the root node and there is only one node at this level. The first level that has octants with respect to its parent node thus is level 1! octant must be in [0;7]. Octant numbering order is unspecified.

Example:

let mut morton_index = MortonIndex64::from_raw(0);
morton_index.set_octant_at_level(3, Octant::ONE);
assert_eq!(Some(Octant::ONE), morton_index.get_octant_at_level(3));

Panics

If level is either zero (see comment above) or level is greater than MortonIndex64::LEVELS.

pub fn set_octant_at_level_unchecked(&mut self, level: u8, octant: u8)[src]

Unchecked version of set_octant_at_level

pub fn get_octant_at_level(&self, level: u8) -> Option<Octant>[src]

Returns the octant index at the specified level in the associated MortonIndex64. level describes the level relative to the root node. Since the root node is only a single node and has no parent, there is no octant at level 0, so None is returned in this case.

Example

let mut morton_index = MortonIndex64::from_raw(0);
morton_index.set_octant_at_level(3, Octant::ONE);
assert_eq!(Some(Octant::ONE), morton_index.get_octant_at_level(3));

Panics

If level is greater than MortonIndex64::LEVELS

pub fn get_octant_at_level_unchecked(&self, level: u8) -> u8[src]

Unchecked version of ‘get_octant_at_level’. In contrast to get_octant_at_level, this always returns zero for level 0 (instead of None). Calling this method with a value for level that is greater than MortonIndex64::LEVELS is undefined behaviour!

pub fn with_depth(&self, depth: u8) -> MortonIndex64WithDepth[src]

Returns a MortonIndex64WithDepth from the associated MortonIndex64 with the given depth

Panics

If depth is greater than MortonIndex64::LEVELS

pub fn as_grid_index(&self) -> Vector3<u32>[src]

Converts the associated MortonIndex64 into an XYZ index within a 3D grid

pub fn to_string(&self, naming: MortonIndexNaming) -> String[src]

Returns a string representation of the associated MortonIndex64 with the given MortonIndexNaming

Trait Implementations

impl Clone for MortonIndex64[src]

impl Copy for MortonIndex64[src]

impl Debug for MortonIndex64[src]

impl Default for MortonIndex64[src]

impl Eq for MortonIndex64[src]

impl From<&'_ u64> for MortonIndex64[src]

impl From<MortonIndex64> for DynamicMortonIndex[src]

impl From<u64> for MortonIndex64[src]

impl Ord for MortonIndex64[src]

impl PartialEq<MortonIndex64> for MortonIndex64[src]

impl PartialOrd<MortonIndex64> for MortonIndex64[src]

impl StructuralEq for MortonIndex64[src]

impl StructuralPartialEq for MortonIndex64[src]

Auto Trait Implementations

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> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,