Janiczek / elm-raycasting / Raycast2D

A library for raycasting geometric tasks in 2D space.

Types


type alias PxCoords =
( Basics.Float, Basics.Float )


type alias TileCoords =
( Basics.Int, Basics.Int )

Raycasting

touchedTiles : Basics.Float -> PxCoords -> PxCoords -> Set TileCoords

This is an Elm implementation of the DDA (Digital Differential Analysis) algorithm popularized by OneLoneCoder (Javidx9).

tileSize = 50
from = (25, 75) -- center of tile (0,1)
to = (275, 175) -- center of tile (5,3)

touchedTiles tileSize from to
--> Set.fromList [(0,1),(1,1),(1,2),(2,2),(3,2),(4,2),(4,3),(5,3)]