I'd meant to do something else this weekend, but I spend a lot of time on a different project. I reimplemented a lot of Mark Dominus' linogram in Python.
I haven't quite decided on the right syntax yet, you can either say constrain( equation_i_want_to_be_true ) or you can use Obj objects like Point, Line, Circle, etc where normal assignment syntax expresses a new constraint.
Behind the scenes it caches each constraint you express, and solves them as a big set of linear equations that it tries to keep in a solved state, dividing them into "variables it knows the answer to" which you can read at any time, and "variables yet to be determined". It rejects new constraints that produce contradictions.
An example of use to solve a set of linear equations would be:
Which gives output:
( Read more... )
I haven't quite decided on the right syntax yet, you can either say constrain( equation_i_want_to_be_true ) or you can use Obj objects like Point, Line, Circle, etc where normal assignment syntax expresses a new constraint.
Behind the scenes it caches each constraint you express, and solves them as a big set of linear equations that it tries to keep in a solved state, dividing them into "variables it knows the answer to" which you can read at any time, and "variables yet to be determined". It rejects new constraints that produce contradictions.
An example of use to solve a set of linear equations would be:
from pylogram import constrain, default_vars as vars constrain( vars.a + vars.b == 2 ) constrain( 2*vars.a + vars.b/3 == -7 ) print( "a , b =", vars.a, ",", vars.b )
Which gives output:
>> -23/5 , 33/5
( Read more... )