Home           About           Downloads





Scripting simulations with ECL



Download: QtEclSmallSimulations2.zip (Win32 binary)

I've been adding to the program mentioned in a previous post. The circuit simulator and origami crease pattern editor are drivable from the lisp repl, and the verlet physics based paper simulator has been implemented and is manipulated from the repl.

Also, the repl itself features command history.

Here is the list of functions currently available from the repl:

ORIGAMI CREASE EDITOR

origami-start
Initialises origami crease editor with a plain sheet of paper consisting of 1 four sided facet.

origami-end
Clears the origami crease editor.

origami-creasecoords
Takes 4 parameters (x1 y1 x2 y2) representing the 2 endpoints of a crease line.

origami-crease
Takes 2 vertex ids (nodeA nodeB) and uses them as the 2 endpoints of a crease line.

origami-creasepp
Takes 2 vertex ids (nodeA nodeB) and forms the crease from "folding" one vertex on the other. The crease line is the perpendicular bisector.

origami-creasell
Takes 4 vertex ids (l1v1 l1v2 l2v1 l2v2) to describe the endpoints of 2 lines, and forms the crease from "folding" one line onto the other.

origami-fold
Takes 3 vertex ids (nodeF nodeA nodeB) and attempts to fold nodeF around the (nodeA nodeB) line by finding its mirror on the other side. It does the same with connected vertices as necessary.

origami-makeverletpaper
Makes a verlet physics representation of the current crease pattern, so it can be manipulated in the verlet physics environment.

VERLET PHYSICS

verlet-lock
Takes 1 vertex id, and fixes that node in space.

verlet-free
Takes 1 vertex id, and frees that node if it was fixed.

verlet-freeall
Removes all position constraints

verlet-rotate
Takes 4 parameters (nodeF nodeA nodeB angle) and rotates nodeF around the axis defined by nodeA and nodeB using the angle parameter. As the system resolves this attempt to do this rotation, you'll see whether the system currently permits or rejects such a motion.

verlet-numnodes
Returns the number of nodes.

verlet-numstruts
Returns the number of struts.

verlet-show
Not implemented - will show the given node id.

verlet-hide
Not implemented - will hide the given node id.

verlet-showall
Not implemented - will show all node ids.

verlet-hideall
Not implemented - will hide all node ids.

verlet-addfstrut
Not implemented - will add a folding strut, which is the same as the crease struts, but is marked as a folding strut, because it can be removed when a given fold is completed.

verlet-addsstrut
Not implemented - will add a structural strut manually. For facets containing more than 3 edges, structural struts are necessary to keep those facets flat. For the crane model, all facets are triangular, so this isn't necessary yet.

verlet-removefstruts
Not implemented - will remove all folding struts.

verlet-removesstruts
Not implemented - will remove all structural struts.

verlet-autoaddsstruts
Not implemented - will automatically add structural struts where needed for facets containing more than 3 edges.

verlet-satisfy
Not implemented - will allow the user to manually invoke the verlet constraint resolver, rather than having it run all the time.

CIRCUIT SIMULATOR

circuit-AddNode
Takes 2 parameters (x y) and adds a new node at that location.

circuit-AddResistor
Takes 3 parameters (nodeA nodeB resistance) and creates a resistor connecting nodeA and nodeB using the resistance parameter.

circuit-AddVoltage
Takes 3 parameters (nodeA nodeB voltage) and creates a voltage source connecting nodeA and nodeB using the voltage parameter.

circuit-AddCurrent
Takes 3 parameters (nodeA nodeB voltage) and creates a current source connecting nodeA and nodeB using the current parameter.

circuit-SetTweenA
Takes 3 parameters (component x y) and adds a tween vertex on one side of the component. For circuit rendering purposes.

circuit-SetTweenB
Takes 3 parameters (component x y) and adds a tween vertex on one side of the component. For circuit rendering purposes.

circuit-DoLoops
Automatically finds the loops in the circuit. It is necessary to call this once modifications to the circuit are complete for the circuit to be simulated correctly.

circuit-Clear
Clears the current circuit.

circuit-ShowCurrent
Turns on the animated rendering of the current.

circuit-ShowComponents
Turns on rendering of the components.

circuit-ShowNodes
Turns on rendering of the nodes.

circuit-ShowLoops
Turns on rendering of the loops.

circuit-HideCurrent
Turns off the animated rendering of the current.

circuit-HideComponents
Turns off rendering of the components.

circuit-HideNodes
Turns off rendering of the nodes.

circuit-HideLoops
Turns off rendering of the loops.

circuit-Rewire
Takes 3 parameters (componentID nodeFrom nodeTo) and disconnects the component from nodeFrom and connects it to nodeTo.

circuit-DeleteComponent
Takes a componentID as a parameter and deletes it.

circuit-DeleteNode
Takes a nodeID as a parameters and deletes it if there is nothing connected to it.

LIVE RENDERING

ogl-renderon
Turn on live rendering

ogl-renderoff
Turn off live rendering

ogl-drawline
Takes 6 parameters (x1 y1 z1 x2 y2 z2) that describe a 3D line, and renders it. This can only be called from within the paper-render function. Redefine the paper-render function at will at runtime.

OLD TEST FUNCTIONS

myadd
Takes 2 parameters and adds them

myaddlist
Takes a list and adds the numbers in the list.

Screenshots:

Press "Execute" when the program starts to load the script which computes the crane crease pattern:



Having a look at the crease pattern in the pattern editor:



Verlet physics paper manipulation and live rendering: Calling verlet-rotate from the repl to rotate the 4 corner vertices at once, 0.1 degrees at a time (the rotation continues due to momentum), then calling ogl-renderon to turn on live rendering, and modifying the paper-render function live by loading live-render.lisp (the function simul-rotate has been defined for convenience to do the simultaneous rotation):


Circuit simulator: Switching to the circuit simulator and loading a circuit (block-circuit.lisp):


Loading the scripts "block-circuit2.lisp" and "block-circuit3.lisp" to modify the circuit: