Z3-based engine implementation. It's very slow, because each step is an HTTP request to start Z3 on the server, solve the system, and return new values. You can try adding and removing rectangles, anything that is a lively.morphic.Box will be constrained to act as a piston, and the morph called "Crank" will be constrained to be the center. So just open the halos on a piston and clone it, the press reset. The constraints are all on the owner. The pistons only have a reset script to set their origin to the center (because that makes the constraints easier). The constraints are used to make polar coordinates for all pistons and the crank, constrain the crank to be on distance 40 from the (central) origin, and then constrain the pistons to have their theta relate to their angle and their position to be determined by a constant distance to the crank. Be patient when clicking "reset", especially if you have a slow connection to lively-kernel.org. It's not optimized and does a request to the server for each constraint, instead of collecting them first. The solving itself is very fast, so the difference between having many pistons or just one isn't too bad, the problem is that the communication with the server is not optimized at all. (In theory, you can also drag any of the pistons or the crank and the thing moves, but the solving-over-http is so slow that it hardly ever works) To modify the step size, change the increase to "crank.t" in the step script. To modify the distance of the crank to the center, modify the constraint on its "r"
Start/Stop
Reset
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// changed at Fri Dec 11 2015 11:09:49 GMT+0100 (Central Europe Standard Time) by timfelgentreff
this.addScript(function reset() {
    this.stopStepping();
    module("users.timfelgentreff.sutherland.relax_bbb").load(true);
    Global.bbb.unconstrainAll(this);
    // ensure a clean slate
    this.submorphs.each(function (ea) {
        Global.bbb.unconstrain(ea, "_Position");
        Global.bbb.unconstrain(ea, "_FixedPosition");
        Global.bbb.unconstrain(ea._Position, "x");
        Global.bbb.unconstrain(ea._Position, "y");
        Global.bbb.unconstrain(ea, "_Rotation");
        Global.bbb.unconstrain(ea, "t");
        Global.bbb.unconstrain(ea, "r");
    });
    // make sure we're centered
    this.setOrigin(pt(this.shape.getBounds().width / 2, this.shape.getBounds().height / 2));
    // setup references
    var pistons = [];
    this.submorphs.each(function (ea) {
        if (ea instanceof lively.morphic.Box) pistons.push(ea);
        if (ea.reset) ea.reset();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<lively.morphic.Box#38BF7... - Z3Engine>
Tag:
run
save
Tests

-- ALL --
reset
setupConstraints
step
Scripts
-
+
-
Connections
+
-- ALL --
all
ObjectEditor -- Z3Engine>>reset
X

Menu