Janiczek/elm-raycasting/1.0.1

Raycast2D

A library for raycasting geometric tasks in 2D space.

Types

type alias PxCoords =
( Float, Float )
type alias TileCoords =
( Int, Int )

Raycasting

touchedTiles : 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)]