Skip to content

DangermonK/dda-ray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

step based Digital Differential Analyzer (DDA) algorithm

#Install

npm i @dangermonk/dda-ray

#Use

initialize a ray from floating point grid coordinates

import { DDARay } from "./index";

const position = {
    x: 2.5, 
    y: 4.2 
};

const vector = {
    x: 2, 
    y: 3
}

const ray = new DDARay(position, vector);

iterate through the grid from the starting point:

ray.nextCell();     // returns the next cell the ray is intersecting with

ray.nextPoint();    // returns the next grid intersection point between cells

ray.next();         // returns point and cell

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published