Safe Haskell | None |
---|---|
Language | Haskell2010 |
DFOV (Digital Field of View) implemented according to specification at http://roguebasin.roguelikedevelopment.org/index.php?title=Digital_field_of_view_implementation. This fast version of the algorithm, based on PFOV, has AFAIK never been described nor implemented before.
- scan :: EnumSet Point -> Distance -> Array Bool -> (Bump -> Point) -> EnumSet Point
- data Bump = B {}
- type Distance = Int
- type Progress = Int
- data Line = Line !Bump !Bump
- type ConvexHull = [Bump]
- type Edge = (Line, ConvexHull)
- type EdgeInterval = (Edge, Edge)
- steeper :: Bump -> Bump -> Bump -> Ordering
- addHull :: (Bump -> Bump -> Ordering) -> Bump -> ConvexHull -> ConvexHull
- dline :: Bump -> Bump -> Line
- dsteeper :: Bump -> Bump -> Bump -> Ordering
- intersect :: Line -> Distance -> (Int, Int)
- _debugSteeper :: Bump -> Bump -> Bump -> Ordering
- _debugLine :: Line -> (Bool, String)
Documentation
:: EnumSet Point | |
-> Distance | visiblity distance |
-> Array Bool | |
-> (Bump -> Point) | coordinate transformation |
-> EnumSet Point |
Calculates the list of tiles, in Bump
coordinates, visible from (0, 0),
within the given sight range.
Scanning coordinate system
Rotated and translated coordinates of 2D points, so that the points fit in a single quadrant area (e, g., quadrant I for Permissive FOV, hence both coordinates positive; adjacent diagonal halves of quadrant I and II for Digital FOV, hence y positive). The special coordinates are written using the standard mathematical coordinate setup, where quadrant I, with x and y positive, is on the upper right.
Assorted minor operations
Current scan parameters
Geometry in system Bump
type ConvexHull = [Bump] Source #
Convex hull represented as a list of points.
type Edge = (Line, ConvexHull) Source #
An edge (comprising of a line and a convex hull) of the area to be scanned.
type EdgeInterval = (Edge, Edge) Source #
The area left to be scanned, delimited by edges.
Internal operations
steeper :: Bump -> Bump -> Bump -> Ordering Source #
Check if the line from the second point to the first is more steep than the line from the third point to the first. This is related to the formal notion of gradient (or angle), but hacked wrt signs to work fast in this particular setup. Returns True for ill-defined lines.
:: (Bump -> Bump -> Ordering) | a comparison function |
-> Bump | a new bump to consider |
-> ConvexHull | a convex hull of bumps represented as a list |
-> ConvexHull |
Extends a convex hull of bumps with a new bump. Nothing needs to be done
if the new bump already lies within the hull. The first argument is
typically steeper
, optionally negated, applied to the second argument.
dsteeper :: Bump -> Bump -> Bump -> Ordering Source #
Compare steepness of (p1, f)
and (p2, f)
.
Debug: Verify that the results of 2 independent checks are equal.
intersect :: Line -> Distance -> (Int, Int) Source #
The X coordinate, represented as a fraction, of the intersection of
a given line and the line of diagonals of diamonds at distance
d
from (0, 0).