Common definitions for the Field of View algorithms. See https://github.com/kosmikus/LambdaHack/wiki/Fov-and-los for some more context and references.
- type Distance = Int
- type Progress = Int
- newtype Bump = B (X, Y)
- type Line = (Bump, Bump)
- type ConvexHull = [Bump]
- type Edge = (Line, ConvexHull)
- type EdgeInterval = (Edge, Edge)
- maximal :: (a -> a -> Bool) -> [a] -> a
- steeper :: Bump -> Bump -> Bump -> Bool
- addHull :: (Bump -> Bump -> Bool) -> Bump -> ConvexHull -> ConvexHull
Current scan parameters
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.
Geometry in system
An edge (comprising of a line and a convex hull) of the area to be scanned.
Assorted minor operations
Maximal element of a non-empty list. Prefers elements from the rear, which is essential for PFOV, to avoid ill-defined lines.
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 -> Bool)|
a comparison function
a new bump to consider
a convex hull of bumps represented as a list
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
steeper, optionally negated, applied to the second argument.