[][src]Struct line_drawing::WalkVoxels

pub struct WalkVoxels<I, O> { /* fields omitted */ }

Walk between two voxels, taking orthogonal steps and visiting all voxels in between.

Implemented from this Stack Overflow answer. This algorithm takes floating-point numbers as input and should be symmetrical.

Example:

extern crate line_drawing;
use line_drawing::{VoxelOrigin, WalkVoxels};
 
fn main() {
    let a = (0.0, 0.0, 0.0);
    let b = (5.0, 6.0, 7.0);

    for (i, (x, y, z)) in WalkVoxels::<f32, i8>::new(a, b, &VoxelOrigin::Center).enumerate() {
        if i > 0 && i % 5 == 0 {
            println!();
        }
        print!("({}, {}, {}), ", x, y, z);
    }
}
(0, 0, 0), (0, 0, 1), (0, 1, 1), (1, 1, 1), (1, 1, 2),
(1, 2, 2), (2, 2, 2), (2, 2, 3), (2, 3, 3), (2, 3, 4),
(3, 3, 4), (3, 4, 4), (3, 4, 5), (4, 4, 5), (4, 5, 5),
(4, 5, 6), (4, 5, 7), (4, 6, 7), (5, 6, 7),

Methods

impl<I: FloatNum, O: SignedNum> WalkVoxels<I, O>[src]

pub fn new(start: Voxel<I>, end: Voxel<I>, origin: &VoxelOrigin) -> Self[src]

Create a new WalkVoxels iterator, with the origin of the voxels.

Important traits for Steps<T, I>
pub fn steps(self) -> Steps<Voxel<O>, Self>[src]

Trait Implementations

impl<I: FloatNum, O: SignedNum> Iterator for WalkVoxels<I, O>[src]

type Item = Voxel<O>

The type of the elements being iterated over.

Auto Trait Implementations

impl<I, O> Send for WalkVoxels<I, O> where
    I: Send,
    O: Send

impl<I, O> Unpin for WalkVoxels<I, O> where
    I: Unpin,
    O: Unpin

impl<I, O> Sync for WalkVoxels<I, O> where
    I: Sync,
    O: Sync

impl<I, O> UnwindSafe for WalkVoxels<I, O> where
    I: UnwindSafe,
    O: UnwindSafe

impl<I, O> RefUnwindSafe for WalkVoxels<I, O> where
    I: RefUnwindSafe,
    O: RefUnwindSafe

Blanket Implementations

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> From<T> for 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.

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

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

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