-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Library for generating grids of hexagons and pentagons mapped to a sphere. -- -- Defines functions for dealing with a type of hexagon grid wrapped -- around a sphere. The full grid is composed of 20 smaller trianglular -- grids of hexagons, that fit together as an icosahedron with pentagons -- at the corners. Each grid cell is assigned an integer value, and we -- can get a list of the neighbors of a particular cell. We can also ask -- for a vector in 3d space that is the center of a particular cell. This -- would be well suited for a game played on a spherical world or a -- planetary environment simulator. @package IcoGrid @version 0.1 module Data.IcoGrid -- | Get a list of all cells in a grid of a given size. The length of this -- list is the number of cells, and they are numberd from 0 to n-1. all_cells :: Int -> [Int] -- | Get all groups of 3 cells that meet at a point in the whole grid (of a -- given size). Each triad is repeated 3 times, with a different cell as -- the first one in the list. all_triads :: Int -> [(Int, Int, Int)] -- | Get a list of neighbors of a particular cell, assuming a grid of a -- certain size. neighbors :: Int -> Int -> [Int] -- | Get the center of a cell as a point in 3-space, assuming a grid of a -- certain size. I have not yet implemented the reverse function, which -- is to find the closest cell to a given point. coord_to_vec :: Int -> Int -> Vec -- | Return list of vectors with the center vertex as head, and then the -- vertex between center and first neighbor, vertex in the middle, and a -- vertex between the center and the second neighbor. Can be drawn with a -- triangle fan. By drawing all the triads in this fashion, one can draw -- the whole grid. I left a little bit of a gap between cells to make the -- edges easier to see. triad_vecs :: Int -> (Int, Int, Int) -> [Vec] instance Eq IcoCoord instance Ord IcoCoord instance Show IcoCoord