From a52866491c41103088ba460bab3663b7bfa86fbb Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Thu, 8 Oct 2020 13:37:51 +0200 Subject: [PATCH] make example a bit nicer --- Reals/Grapher.mch | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Reals/Grapher.mch b/Reals/Grapher.mch index e64de01..11e458e 100644 --- a/Reals/Grapher.mch +++ b/Reals/Grapher.mch @@ -3,15 +3,23 @@ DEFINITIONS "LibraryReals.def"; "LibraryStrings.def"; - // generate a SVG points attribute string (e.g. for polygons) from a sequence of pairs of integers: - svg_points2str(points) == conc(%i.(i:dom(points)| + // generate a SVG points attribute string (e.g. for polygons) from a sequence of pairs of integers: + svg_points2str(points) == conc(%i.(i:dom(points)| FORMAT_TO_STRING("~w,~w ",[real(i), points(i)]))); - // the function to be plotted: - myfunction(x) == 2.0*RSQRT(x)-0.5*RSIN(2.0*x); + // the function to be plotted: + myfunction(x) == 1.5*RSQRT(x)-0.5*RSIN(2.0*x); + + // proportions of the SVG frame + WIDTH == 500; + HEIGHT == 300; + + mx_x == 10.0; // maximum x value computed - mypoints(scale) == %x.(x:1..500| 300.0-scale*myfunction(RDIV(real(x),scale))); + // compute a sequence of function values: + mypoints(scale) == %x.(x:1..WIDTH| real(HEIGHT) - + scale*myfunction(RDIV(real(x),scale))); - // graph plotted in rectangle (0,0) to (300,300) - visb_graph == svg_points2str(mypoints(30.0)) + // graph plotted in rectangle (0,0) to (500,300) + visb_graph == svg_points2str(mypoints(RDIV(real(WIDTH),mx_x))) END \ No newline at end of file -- GitLab