| Copyright | Brent Yorgey |
|---|---|
| License | BSD-3-Clause |
| Maintainer | byorgey@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Util.Location
Contents
Description
Locations and headings.
Documentation
type Location = Point V2 Int32 Source #
A Location is a pair of (x,y) coordinates, both up to 32 bits. The positive x-axis points east and the positive y-axis points north. These are the coordinates that are shown to players.
See also the Coords type defined in Swarm.Game.World, which
use a (row, column) format instead, which is more convenient for
internal use. The Swarm.Game.World module also defines
conversions between Location and Coords.
pattern Location :: Int32 -> Int32 -> Location Source #
A convenient way to pattern-match on Location values.
origin :: forall (f :: Type -> Type) a. (Additive f, Num a) => Point f a #
Vector spaces have origins.
class Additive (Diff p) => Affine (p :: Type -> Type) where #
An affine space is roughly a vector space in which we have forgotten or at least pretend to have forgotten the origin.
a .+^ (b .-. a) = b@ (a .+^ u) .+^ v = a .+^ (u ^+^ v)@ (a .-. b) ^+^ v = (a .+^ v) .-. q@
Methods
(.-.) :: Num a => p a -> p a -> Diff p a infixl 6 #
Get the difference between two points as a vector offset.
(.+^) :: Num a => p a -> Diff p a -> p a infixl 6 #
Add a vector offset to a point.
(.-^) :: Num a => p a -> Diff p a -> p a infixl 6 #
Subtract a vector offset from a point.
Instances
| Affine ZipList | |
| Affine Complex | |
| Affine Identity | |
| Affine IntMap | |
| Affine Plucker | |
| Affine Quaternion | |
Defined in Linear.Affine Associated Types type Diff Quaternion :: Type -> Type # Methods (.-.) :: Num a => Quaternion a -> Quaternion a -> Diff Quaternion a # (.+^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a # (.-^) :: Num a => Quaternion a -> Diff Quaternion a -> Quaternion a # | |
| Affine V0 | |
| Affine V1 | |
| Affine V2 | |
| Affine V3 | |
| Affine V4 | |
| Affine Vector | |
| Affine Maybe | |
| Affine [] | |
| Ord k => Affine (Map k) | |
| Additive f => Affine (Point f) | |
| (Eq k, Hashable k) => Affine (HashMap k) | |
| Dim n => Affine (V n) | |
| (Affine f, Affine g) => Affine (Product f g) | |
Defined in Linear.Affine | |
| Affine ((->) b) | |