packages feed

grid 7.0 → 7.1

raw patch · 3 files changed

+50/−44 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Math.Geometry.Grid.Triangular: data XCylTriGrid
+ Math.Geometry.Grid.Triangular: data YCylTriGrid
+ Math.Geometry.Grid.Triangular: xCylTriGrid :: Int -> Int -> XCylTriGrid
+ Math.Geometry.Grid.Triangular: yCylTriGrid :: Int -> Int -> YCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: XCylTriGrid :: (Int, Int) -> [(Int, Int)] -> XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: data XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: instance Eq XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: instance FiniteGrid XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: instance Grid XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: instance Show XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: instance WrappedGrid XCylTriGrid
+ Math.Geometry.Grid.TriangularInternal: xCylTriGrid :: Int -> Int -> XCylTriGrid

Files

grid.cabal view
@@ -1,5 +1,5 @@ name:           grid-version:        7.0+version:        7.1 synopsis:       Tools for working with regular grids (graphs, lattices). description:    Provides tools for working with regular arrangements                 of tiles, such as might be used in a board game or some
src/Math/Geometry/Grid/Triangular.hs view
@@ -31,9 +31,15 @@     rectTriGrid,     -- * Toroidal grid with triangular tiles     TorTriGrid,-    torTriGrid+    torTriGrid,+    -- * Cylindrical grids with triangular tiles+    YCylTriGrid,+    yCylTriGrid,+    XCylTriGrid,+    xCylTriGrid   ) where -import Math.Geometry.Grid.TriangularInternal (UnboundedTriGrid, TriTriGrid, -  triTriGrid, ParaTriGrid, paraTriGrid, RectTriGrid, rectTriGrid, -  TorTriGrid, torTriGrid)+import Math.Geometry.Grid.TriangularInternal (UnboundedTriGrid,+  TriTriGrid, triTriGrid, ParaTriGrid, paraTriGrid,+  RectTriGrid, rectTriGrid, TorTriGrid, torTriGrid,+  YCylTriGrid, yCylTriGrid, XCylTriGrid, xCylTriGrid)
src/Math/Geometry/Grid/TriangularInternal.hs view
@@ -321,48 +321,48 @@ yCylTriGrid :: Int -> Int -> YCylTriGrid yCylTriGrid r c = YCylTriGrid (r,c) (parallelogramIndices r c) --- -- | A cylindrical grid with triangular tiles, where the cylinder is--- --   along the x-axis.--- --   The grid and its indexing scheme are illustrated in the user guide,--- --   available at <https://github.com/mhwombat/grid/wiki>.--- data XCylTriGrid = XCylTriGrid (Int, Int) [(Int, Int)] deriving Eq+-- | A cylindrical grid with triangular tiles, where the cylinder is+--   along the x-axis.+--   The grid and its indexing scheme are illustrated in the user guide,+--   available at <https://github.com/mhwombat/grid/wiki>.+data XCylTriGrid = XCylTriGrid (Int, Int) [(Int, Int)] deriving Eq --- instance Show XCylTriGrid where ---   show (XCylTriGrid (r,c) _) = "yCylTriGrid " ++ show r ++ " " ++ show c+instance Show XCylTriGrid where +  show (XCylTriGrid (r,c) _) = "yCylTriGrid " ++ show r ++ " " ++ show c --- instance Grid XCylTriGrid where---   type Index XCylTriGrid = (Int, Int)---   type Direction XCylTriGrid = TriDirection---   indices (XCylTriGrid _ xs) = xs---   neighbours = neighboursWrappedBasedOn UnboundedTriGrid---   neighbour = neighbourWrappedBasedOn UnboundedTriGrid---   distance = distanceWrappedBasedOn UnboundedTriGrid---   directionTo = directionToWrappedBasedOn UnboundedTriGrid---   isAdjacent g a b = distance g a b <= 1---   contains g (x, y) = 0 <= x && x <= 2*c-1 && even (x+y) ---     where (_, c) = size g+instance Grid XCylTriGrid where+  type Index XCylTriGrid = (Int, Int)+  type Direction XCylTriGrid = TriDirection+  indices (XCylTriGrid _ xs) = xs+  neighbours = neighboursWrappedBasedOn UnboundedTriGrid+  neighbour = neighbourWrappedBasedOn UnboundedTriGrid+  distance = distanceWrappedBasedOn UnboundedTriGrid+  directionTo = directionToWrappedBasedOn UnboundedTriGrid+  isAdjacent g a b = distance g a b <= 1+  contains g (x, y) = 0 <= x && x <= 2*c-1 && even (x+y) +    where (_, c) = size g --- instance FiniteGrid XCylTriGrid where---   type Size XCylTriGrid = (Int, Int)---   size (XCylTriGrid s _) = s---   maxPossibleDistance g = -- TODO: make more efficient---     maximum . map (distance g (0,0)) . indices $ g+instance FiniteGrid XCylTriGrid where+  type Size XCylTriGrid = (Int, Int)+  size (XCylTriGrid s _) = s+  maxPossibleDistance g = -- TODO: make more efficient+    maximum . map (distance g (0,0)) . indices $ g --- instance WrappedGrid XCylTriGrid where---   normalise g (x,y) | y < 0     = normalise g (x,y+2*r)---                     | y > 2*r-1 = normalise g (x,y-2*r)---                     | otherwise = (x,y)---     where (r, _) = size g---   denormalise g a = nub [ (x,y-2*r), (x,y), (x,y+2*r) ]---     where (r, _) = size g---           (x, y) = normalise g a+instance WrappedGrid XCylTriGrid where+  normalise g (x,y) | y < 0     = normalise g (x,y+2*r)+                    | y > 2*r-1 = normalise g (x,y-2*r)+                    | otherwise = (x,y)+    where (r, _) = size g+  denormalise g a = nub [ (x,y-2*r), (x,y), (x,y+2*r) ]+    where (r, _) = size g+          (x, y) = normalise g a --- -- | @'xCylTriGrid' r c@ returns a cylindrical grid with @r@ rows and --- --   @c@ columns, using triangular tiles, where the cylinder is along --- --   the y-axis. The indexing method is the same as for @ParaTriGrid@. --- --   If @r@ and @c@ are both nonnegative, the resulting grid will have --- --   @2*r*c@ tiles. Otherwise, the resulting grid will be null and the --- --   list of indices will be null.--- xCylTriGrid :: Int -> Int -> XCylTriGrid--- xCylTriGrid r c = XCylTriGrid (r,c) (parallelogramIndices r c)+-- | @'xCylTriGrid' r c@ returns a cylindrical grid with @r@ rows and +--   @c@ columns, using triangular tiles, where the cylinder is along +--   the y-axis. The indexing method is the same as for @ParaTriGrid@. +--   If @r@ and @c@ are both nonnegative, the resulting grid will have +--   @2*r*c@ tiles. Otherwise, the resulting grid will be null and the +--   list of indices will be null.+xCylTriGrid :: Int -> Int -> XCylTriGrid+xCylTriGrid r c = XCylTriGrid (r,c) (parallelogramIndices r c)