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

add example DEFINITION file using new VisB features

parent 3b0b119c
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ MACHINE VectorVisualisation
// Small visualisation to show two vectors and various operations on them
DEFINITIONS
NVECS==2;
// "VectorVisualisationVisB.def"; // can now be used as alternative
VISB_JSON_FILE == "vector_visualisation_visb.json";
"LibrarySVG.def"
INCLUDES Vectors2
......@@ -14,6 +15,8 @@ OPERATIONS
vectors(i) := times_vec(k,vectors(i))
END;
AddVec = BEGIN vectors(1):= add_vec(vectors(1),vectors(2)) END;
SubVec1 = BEGIN vectors(1):= [vectors(1)(1)-vectors(2)(1), vectors(1)(2)-vectors(2)(2)] END;
SubVec2 = BEGIN vectors(1):= [vectors(2)(1)-vectors(1)(1), vectors(2)(2)-vectors(1)(2)] END;
MakeUnit(i) = PRE i:dom(vectors) THEN vectors(i):= unit_vec(vectors(i)) END;
SwapXY(i) = PRE i:dom(vectors) THEN vectors(i):= rev(vectors(i)) END;
Opposite(i) = PRE i:dom(vectors) THEN vectors(i):= [-vectors(i)(1),-vectors(i)(2)] END
......
DEFINITIONS
"LibrarySVG.def";
"LibraryStrings.def";
SCALE100 == 0.05;
VISB_JSON_FILE == "";
VISB_SVG_OBJECTS1 == rec(
svg_class:"circle",
`id`:"origin",
cx:0,
cy:0,
r:5,
`stroke-width`:0.0,
fill:"green");
VISB_SVG_OBJECTS2 == ran(%vec.(vec:1..NVECS|
rec(
svg_class:"line",
`id`:"vector_"^TO_STRING(vec),
x1:0,
y1:0,
x2:5,
y2:5,
stroke:IF vec=1 THEN "blue" ELSIF vec=2 THEN "green" ELSE "#000" END,
`stroke-width`:1.75,
`marker-end`:"url(#arrowhead)"
)));
VISB_SVG_UPDATES2 == ran(%vec.(vec:1..NVECS|
rec(
`id`:"vector_"^TO_STRING(vec),
x2:vectors(vec)(1) / SCALE100,
y2:-vectors(vec)(2)/ SCALE100
)));
VISB_SVG_UPDATES3 ==
rec(
`id`:"axis",
points:svg_axis(0..10,1.0/SCALE100,10.0/SCALE100,0.2/SCALE100)
);
VISB_SVG_BOX == rec(height:500,width:500,viewBox:"-250 -250 500 600");
VISB_SVG_CONTENTS == '''
<defs>
<marker id="arrowhead" markerWidth="10" markerHeight="7"
refX="0" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" />
</marker>
<marker id="startarrow" markerWidth="10" markerHeight="7"
refX="10" refY="3.5" orient="auto">
<polygon points="10 0, 10 7, 0 3.5" fill="green" />
</marker>
<marker id="endarrow" markerWidth="10" markerHeight="7"
refX="0" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="green" />
</marker>
</defs>
<polyline points = "0 0, 100 100" id="axis" stroke="gray" />
<text text-align="left" x="250" y="30"
font-size ="20" fill="blue" font-family="sans-serif">
<tspan id="vec_1_0_txt">v1</tspan>
</text>
<text text-align="left" x="250" y="50"
font-size ="20" fill="blue" font-family="sans-serif">
<tspan id="vec_1_1_txt">x(1)</tspan>
</text>
<text text-align="left" x="250" y="70"
font-size ="20" fill="blue" font-family="sans-serif">
<tspan id="vec_1_2_txt">x(2)</tspan>
</text>
<text text-align="left" x="250" y="-70"
font-size ="20" fill="green" font-family="sans-serif">
<tspan id="vec_2_0_txt">v2</tspan>
</text>
<text text-align="left" x="250" y="-50"
font-size ="20" fill="green" font-family="sans-serif">
<tspan id="vec_2_1_txt">x(1)</tspan>
</text>
<text text-align="left" x="250" y="-30"
font-size ="20" fill="green" font-family="sans-serif">
<tspan id="vec_2_2_txt">x(2)</tspan>
</text>
'''
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment