Skip to content
Snippets Groups Projects
Commit 4b6e8dfb authored by Michael Leuschel's avatar Michael Leuschel
Browse files

add simple example plotting a real function

parent 6ce491e6
No related branches found
No related tags found
No related merge requests found
{
"svg": "Grapher.svg",
"items": [
{
"id": "fungraph",
"attr": "points",
"value": "visb_graph"
}
],
"events": [
]
}
\ No newline at end of file
MACHINE Grapher
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)|
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);
mypoints(scale) == %x.(x:1..500| 300.0-scale*myfunction(RDIV(real(x),scale)));
// graph plotted in rectangle (0,0) to (300,300)
visb_graph == svg_points2str(mypoints(30.0))
END
\ No newline at end of file
This diff is collapsed.
<svg height="300" width="500">
<polyline id = "fungraph"
points="0,0 0,1 10,1 10,0 90,0 90,1 100,1 100,0"
stroke="black"
fill="none"
opacity="0.70"
/>
<rect x="0" y="0" width="500" height="300" fill="none" stroke="black">
</svg>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment