goal-geometry-0.1: scripts/coordinates.hs
--- Imports ---
import Goal.Core
import Goal.Geometry
--- Program ---
-- Globals --
mxx = pi
mnx = -pi
mxy = pi
mny = -pi
nstps = 10
npnts = 50
axprms = LinearAxisParams (show . round) 5 5
hlns = [ [ [x,y] | x <- range mnx mxx npnts ] | y <- range mnx mxx nstps ]
vlns = [ [ [x,y] | y <- range mny mxy npnts ] | x <- range mny mxy nstps ]
lns0 = hlns ++ vlns
eclds = map euclideanPoint <$> lns0
plrs = map (chart Cartesian . transition . chart Polar . fromList (Euclidean 2)) <$> lns0
layoutMaker lns = execEC $ do
layout_x_axis . laxis_override .= axisGridHide
layout_x_axis . laxis_generate .= scaledAxis axprms (-2,2)
layout_x_axis . laxis_title .= "x"
layout_y_axis . laxis_override .= axisGridHide
layout_y_axis . laxis_generate .= scaledAxis axprms (-2,2)
layout_y_axis . laxis_title .= "y"
plot . liftEC $ do
plot_lines_values .= (map toPair <$> lns)
plot_lines_style .= solidLine 3 (opaque black)
-- Main --
main = do
let lyt1 = layoutMaker eclds
lyt2 = layoutMaker plrs
rnbl = toRenderable $ StackedLayouts [StackedLayout lyt1, StackedLayout lyt2] False
--renderableToAspectWindow False 400 800 rnbl
void $ renderableToFile (FileOptions (200,400) PDF) "coordinates.pdf" rnbl