Skip to content

StrandedKitty/tiles-intersect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiles-intersect

Given two points which represent a line in 2D or 3D space find all tiles/voxels it intersects. It's a JavaScript implementation of A Fast Voxel Traversal Algorithm for Ray Tracing.

Usage

const tilesIntersect = require('tiles-intersect');
let line = [[0.1, 0.2], [3.5, 2.8]];
let tiles = tilesIntersect.calculate(line, 2); // [[0, 0], [1, 0], [1, 1], [2, 1], [2, 2], [3, 2]]

API

calculate(line, dimensions = 2)

Returns a 2D array of tiles/voxels intersected by a line.

line

Two-dimensional array which contains two points.

dimensions

Number of dimensions (2 or 3).

About

Find all tiles or voxels intersected by a line segment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published