constraints - Geometric constraints on primitive
This modules defines the constraints definitions and the solver tools
Constraints can be any object referencing variables
and implementing the following signature to guide the solver in the resolution:
class SomeConstraint:
# name the attributes referencing the solver variables to change
slvvars = 'some_primitive', 'some_point'
# function returning the squared error in the constraint
# for a coincident constraint for instance it's the squared distance
# the error must be a contiguous function of the parameters, and it's squared for numeric stability reasons.
# the solver internally use an iterative approach to optimize the sum of all fit functions.
def fit((self):
...
Solver
-
class
Problem
(constraints, fixed=())[source] Class to holds data for a problem solving process. it is intended to be instantiated for each different probleme solving, an instance is used multiple times only when we want to solve on top of the previous results, using exactly the same probleme definition (constraints and variables)
- Therefore the solver protocol is the following:
- constraints define the problem
- each constraint refers to variables it applies on
- constraints have the method fit() and a member ‘slvvars’ that can be
- An iterable of names of variable members in the constraint object
- A function returning an iterable of the actual variables objects (that therefore must be referenced refs and not primitive types)
- each variable object can redirect to other variable objects if they implements such a member ‘slvvars’
- primitives can also be constraints on their variables, thus they must have a method fit() (but no member ‘primitives’ here)
- primitives can implement the optional solver methods for some constraints, such as ‘slv_tangent’
Constraints definitions
-
class
Radius
(arc, radius)[source] Gets the given Arc with the given fixed radius
Note: Only ArcCentered are supported yet.