1 -- This file is part of Intricacy
2 -- Copyright (C) 2013 Martin Bays <mbays@sdf.org>
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of version 3 of the GNU General Public License as
6 -- published by the Free Software Foundation, or any later version.
8 -- You should have received a copy of the GNU General Public License
9 -- along with this program. If not, see http://www.gnu.org/licenses/.
16 data CVec
= CVec
{ cy
, cx
:: Int }
17 deriving (Eq
, Ord
, Show)
18 instance Monoid CVec
where
20 mappend
(CVec y x
) (CVec y
' x
') = CVec
(y
+y
') (x
+x
')
21 instance Grp CVec
where
22 neg
(CVec y x
) = CVec
(-y
) (-x
)
23 type CCoord
= PHS CVec
25 hexVec2CVec
:: HexVec
-> CVec
26 hexVec2CVec
(HexVec x y z
) = CVec
(-y
) (x
-z
)
27 cVec2HexVec
:: CVec
-> HexVec
28 cVec2HexVec
(CVec y x
) = HexVec
((x
+y
)`
div`
2) (-y
) ((y
-x
)`
div`
2)
30 truncateCVec
:: CVec
-> CVec
31 truncateCVec
(CVec x y
) = CVec
(max 0 x
) (max 0 y
)