Safe Haskell | None |
---|---|
Language | Haskell2010 |
AOC.Common.Point
Synopsis
- type Point = V2 Int
- type FinPoint n = V2 (Finite n)
- cardinalNeighbs :: Point -> [Point]
- cardinalNeighbsSet :: Point -> Set Point
- fullNeighbs :: (Applicative f, Num a, Traversable f) => f a -> [f a]
- fullNeighbsSet :: (Applicative f, Num a, Ord (f a), Traversable f) => f a -> Set (f a)
- mannDist :: (Foldable f, Num a, Num (f a)) => f a -> f a -> a
- mulPoint :: Num a => V2 a -> V2 a -> V2 a
- lineTo :: Point -> Point -> [Point]
- data Dir
- parseDir :: Char -> Maybe Dir
- dirPoint :: Num a => Dir -> V2 a
- dirPoint' :: Num a => Dir -> V2 a
- rotPoint :: Num a => Dir -> V2 a -> V2 a
- rotFin :: KnownNat n => Dir -> FinPoint n -> FinPoint n
- mulDir :: Dir -> Dir -> Dir
- allDir :: NonEmpty Dir
- allDirSet :: NESet Dir
- data D8 = D8 {}
- mulD8 :: D8 -> D8 -> D8
- orientPoint :: Num a => D8 -> V2 a -> V2 a
- orientFin :: KnownNat n => D8 -> FinPoint n -> FinPoint n
- allD8 :: NonEmpty D8
- allD8Set :: NESet D8
- memoPoint :: Memo Point
- boundingBox :: (Foldable1 f, Applicative g, Ord a) => f (g a) -> V2 (g a)
- boundingBox' :: (Foldable f, Applicative g, Ord a) => f (g a) -> Maybe (V2 (g a))
- inBoundingBox :: (Applicative g, Foldable g, Ord a) => V2 (g a) -> g a -> Bool
- minCorner :: (Foldable1 f, Applicative g, Ord a) => f (g a) -> g a
- minCorner' :: (Foldable f, Applicative g, Ord a) => f (g a) -> Maybe (g a)
- shiftToZero :: (Applicative f, Num a, Ord a) => NESet (f a) -> NESet (f a)
- shiftToZero' :: (Applicative f, Num a, Ord a) => Set (f a) -> Set (f a)
- parseAsciiMap :: (Char -> Maybe a) -> String -> Map Point a
- asciiGrid :: IndexedTraversal Point String [a] Char a
- parseAsciiSet :: (Char -> Bool) -> String -> Set Point
- newtype ScanPoint = SP {}
- displayAsciiMap :: Char -> Map Point Char -> String
- displayAsciiSet :: Char -> Char -> Set Point -> String
- centeredFinite :: forall n. KnownNat n => Iso' (Finite n) Rational
Points
cardinalNeighbs :: Point -> [Point] Source #
fullNeighbs :: (Applicative f, Num a, Traversable f) => f a -> [f a] Source #
fullNeighbsSet :: (Applicative f, Num a, Ord (f a), Traversable f) => f a -> Set (f a) Source #
mulPoint :: Num a => V2 a -> V2 a -> V2 a Source #
Treat as complex number multiplication. useful for rotations
lineTo :: Point -> Point -> [Point] Source #
Lattice points for line between points, not including endpoints
Directions
Instances
Enum Dir Source # | |
Eq Dir Source # | |
Ord Dir Source # | |
Show Dir Source # | |
Generic Dir Source # | |
Semigroup Dir Source # | |
Monoid Dir Source # | |
NFData Dir Source # | |
Defined in AOC.Common.Point | |
Hashable Dir Source # | |
Defined in AOC.Common.Point | |
Finitary Dir Source # | |
Abelian Dir Source # | |
Defined in AOC.Common.Point | |
Group Dir Source # | |
type Rep Dir Source # | |
Defined in AOC.Common.Point type Rep Dir = D1 ('MetaData "Dir" "AOC.Common.Point" "aoc2020-0.1.0.0-FyPlSv9LBbs5G4MoObRXVm" 'False) ((C1 ('MetaCons "North" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "East" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "South" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "West" 'PrefixI 'False) (U1 :: Type -> Type))) | |
type Cardinality Dir Source # | |
Defined in AOC.Common.Point |
mulDir :: Dir -> Dir -> Dir Source #
Multiply headings, taking North as straight, East as clockwise turn, West as counter-clockwise turn, and South as reverse.
Should be a commutative group; it's essentially complex number
multiplication like mulPoint
, with North = 1, West = i. The identity
is North
and the inverse is the opposite direction.
Orientations
Represents an orientation of a 2d tile.
Instances
Eq D8 Source # | |
Ord D8 Source # | |
Show D8 Source # | |
Generic D8 Source # | |
Semigroup D8 Source # | |
Monoid D8 Source # | |
NFData D8 Source # | |
Defined in AOC.Common.Point | |
Hashable D8 Source # | |
Defined in AOC.Common.Point | |
Finitary D8 Source # | |
Group D8 Source # | |
type Rep D8 Source # | |
Defined in AOC.Common.Point type Rep D8 = D1 ('MetaData "D8" "AOC.Common.Point" "aoc2020-0.1.0.0-FyPlSv9LBbs5G4MoObRXVm" 'False) (C1 ('MetaCons "D8" 'PrefixI 'True) (S1 ('MetaSel ('Just "d8Rot") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Dir) :*: S1 ('MetaSel ('Just "d8Flip") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))) | |
type Cardinality D8 Source # | |
Defined in AOC.Common.Point |
2D Maps
boundingBox :: (Foldable1 f, Applicative g, Ord a) => f (g a) -> V2 (g a) Source #
Find the minimum and maximum x and y from a collection of points.
Returns
.V2
(V2 xMin yMin) (V2 xMax yMax)
boundingBox' :: (Foldable f, Applicative g, Ord a) => f (g a) -> Maybe (V2 (g a)) Source #
A version of boundingBox
that works for normal possibly-empty lists.
inBoundingBox :: (Applicative g, Foldable g, Ord a) => V2 (g a) -> g a -> Bool Source #
minCorner :: (Foldable1 f, Applicative g, Ord a) => f (g a) -> g a Source #
minCorner' :: (Foldable f, Applicative g, Ord a) => f (g a) -> Maybe (g a) Source #
shiftToZero :: (Applicative f, Num a, Ord a) => NESet (f a) -> NESet (f a) Source #
Shift corner to (0,0)
shiftToZero' :: (Applicative f, Num a, Ord a) => Set (f a) -> Set (f a) Source #
Shift corner to (0,0)
Instances
Eq ScanPoint Source # | |
Num ScanPoint Source # | |
Defined in AOC.Common.Point | |
Ord ScanPoint Source # | |
Show ScanPoint Source # | |
Generic ScanPoint Source # | |
NFData ScanPoint Source # | |
Defined in AOC.Common.Point | |
Hashable ScanPoint Source # | |
Defined in AOC.Common.Point | |
type Rep ScanPoint Source # | |
Defined in AOC.Common.Point |
Util
Orphan instances
(Finitary a, KnownNat (Cardinality a), KnownNat (Cardinality a * Cardinality a)) => Finitary (V2 a) Source # | |
(Finitary a, KnownNat (Cardinality a), KnownNat (Cardinality a * (Cardinality a * Cardinality a))) => Finitary (V3 a) Source # | |
(Finitary a, KnownNat (Cardinality a), KnownNat ((Cardinality a * Cardinality a) * (Cardinality a * Cardinality a))) => Finitary (V4 a) Source # | |