Skip to content

Rust implementation of Amantides and Woo algorithm for casting a ray through pixels or voxels.

License

Notifications You must be signed in to change notification settings

bonsairobo/grid-ray-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grid-ray

THIS PROJECT IS MAINTAINED HERE NOW

An iterator-based implementation of the Amantides and Woo algorithm for casting a ray through pixels or voxels.

Code Example

use grid_ray::GridRayIter3;
use grid_ray::ilattice::glam::{const_ivec3, const_vec3a};

let start = const_vec3a!([0.5, 0.5, 0.5]);
let direction = const_vec3a!([1.0, -2.0, 3.0]);
let mut traversal = GridRayIter3::new(start, direction);

assert_eq!(
    traversal.take(10).collect::<Vec<_>>(),
    vec![
        (0.0, const_ivec3!([0, 0, 0])),
        (0.16666667, const_ivec3!([0, 0, 1])),
        (0.25, const_ivec3!([0, -1, 1])),
        (0.5, const_ivec3!([0, -1, 2])),
        (0.5, const_ivec3!([1, -1, 2])),
        (0.75, const_ivec3!([1, -2, 2])),
        (0.8333334, const_ivec3!([1, -2, 3])),
        (1.1666667, const_ivec3!([1, -2, 4])),
        (1.25, const_ivec3!([1, -3, 4])),
        (1.5, const_ivec3!([2, -3, 4])),
    ]
);

License: MIT OR Apache-2.0

About

Rust implementation of Amantides and Woo algorithm for casting a ray through pixels or voxels.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages