Struct pasture_core::math::MortonIndex64 [−][src]
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]
fn clone(&self) -> MortonIndex64
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[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]
fn from(morton_index: MortonIndex64) -> Self
[src]
impl From<u64> for MortonIndex64
[src]
impl Ord for MortonIndex64
[src]
fn cmp(&self, other: &Self) -> 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<MortonIndex64> for MortonIndex64
[src]
fn eq(&self, other: &MortonIndex64) -> bool
[src]
fn ne(&self, other: &MortonIndex64) -> bool
[src]
impl PartialOrd<MortonIndex64> for MortonIndex64
[src]
fn partial_cmp(&self, other: &MortonIndex64) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for MortonIndex64
[src]
impl StructuralPartialEq for MortonIndex64
[src]
Auto Trait Implementations
impl RefUnwindSafe for MortonIndex64
impl Send for MortonIndex64
impl Sync for MortonIndex64
impl Unpin for MortonIndex64
impl UnwindSafe for MortonIndex64
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> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
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]
T: Copy + PartialEq<T> + Debug + Any,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,