Fix clockwise rotation

This commit is contained in:
Sam Tay 2017-06-17 21:30:57 -04:00
parent ef6ed845c2
commit e64715d051

View file

@ -116,16 +116,8 @@ rotate' b@(Block s o@(xo,yo) cs)
| otherwise = rotateWith counterclockwise b | otherwise = rotateWith counterclockwise b
where where
rotateWith :: (Coord -> Coord -> Coord) -> Block -> Block rotateWith :: (Coord -> Coord -> Coord) -> Block -> Block
rotateWith dir b = b & extra %~ fmap (dir (b ^. origin)) rotateWith dir b = b & extra %~ fmap (dir (b ^. origin))
clockwise (xo, yo) (x, y) = (xo + y - yo, xo + yo - x)
clockwise :: Coord -- ^ origin
-> Coord -- ^ point to rotate around origin
-> Coord
clockwise (xo, yo) (x, y) = (xo + y - yo, xo + y - x)
counterclockwise :: Coord -- ^ origin
-> Coord -- ^ point to rotate around origin
-> Coord
counterclockwise (xo, yo) (x, y) = (xo + yo - y, x + yo - xo) counterclockwise (xo, yo) (x, y) = (xo + yo - y, x + yo - xo)
-- | Get coordinates of entire block -- | Get coordinates of entire block