Ezpz
This is a 2D constraint solver, for use in CAD or graphics applications.
Usage
use ;
// Define the geometry.
// These entities don't have known positions or dimensions yet, the solver
// will place them for us.
let mut ids = default;
let p = new;
let q = new;
// Define constraints on the geometry.
// These could constraint the entities themselves
// (e.g. the position of a point or the radius of a circle),
// or their relationship to each other
// (e.g. these two lines must be parallel, or this point must lie on this arc).
let requests = ;
// Provide some initial guesses to the solver for their locations.
let initial_guesses = vec!;
// Run the solver!
let outcome = solve;
// Check the outcome.
match outcome
Constraint problem files
ezpz defines a text format for writing out constraint problems. You don't have to use this format -- you can use the Rust library directly -- but it's a very convenient format. It looks like this:
point p
point q
p.x = 0
p.y = 0
q.y = 0
vertical(p, q)
p roughly (3, 4)
q roughly (5, 6)
There's two sections, Constraints and Guesses. You define each point (like p and q) and once defined, you can write constraints that use them. For example, you can fix a point's X or Y component (p.x = 0). Or you can relate two points, e.g. vertical(p, q).
For more examples, see the test_cases/ directory.