API documentation¶
pygeosolve.constraints module¶
Constraints.
- class pygeosolve.constraints.Constraint(primitives)[source]¶
Bases:
objectA constraint between primitives.
A constraint is defined between one or more
Primitiveobjects. This class defines the interface for concrete constraints to determine their error in the current problem using these primitives.- Parameters
- primitivessequence
The primitives associated with this constraint.
- property params¶
The parameters associated with the points within this constraint.
- property points¶
The points associated with the primitives associated with this constraint.
- class pygeosolve.constraints.LineAngleConstraint(line_a, line_b, angle)[source]¶
Bases:
pygeosolve.constraints.ConstraintConstraint on the angle between two lines.
- Parameters
- line_a, line_b
Line The lines to constrain.
- angle
float The angle (in degrees) to constrain the lines to.
- line_a, line_b
- property angle¶
- property line_a¶
- property line_b¶
- class pygeosolve.constraints.LineLengthConstraint(line, length)[source]¶
Bases:
pygeosolve.constraints.ConstraintConstraint on the length of a line.
- Parameters
- line
Line The line to constrain.
- length
float The length to constrain the line to.
- line
- property length¶
The constraint length.
- property line¶
- class pygeosolve.constraints.PointToPointDistanceConstraint(point_a, point_b, distance)[source]¶
Bases:
pygeosolve.constraints.ConstraintConstraint on the distance between two points.
- Parameters
- point_a, point_b
Point The points to constrain.
- distance
float The distance to constrain the points’ separation to.
- point_a, point_b
- property point_a¶
- property point_b¶
pygeosolve.geometry module¶
Geometry.
- class pygeosolve.geometry.Line(name, start, end)[source]¶
Bases:
pygeosolve.geometry.PrimitiveA line formed between two 2D points in Euclidean space.
- Parameters
- start, end
tuplecontaing twofloatsor
- start, end
- angle()[source]¶
The angle of the vector formed by this line translated to the origin.
- Returns
floatThe angle, in degrees, in the range (-180, 180].
- angle_to(other)[source]¶
The angle to other line with respect to this one.
The angle is defined as the clockwise rotation from the direction of self to get to the direction of other.
- Parameters
- other
Line The other line.
- other
- Returns
floatThe angle, in degrees, in the range (-180, 180].
- property end¶
- property start¶
- class pygeosolve.geometry.Point(name, x, y)[source]¶
Bases:
pygeosolve.geometry.PrimitiveA 2D point in Euclidean space.
Normally points should not be instantiated directly, but via
primitives.- Parameters
- name
str The name of this point.
- x, y
float The x and y coordinates.
- name
- property x¶
- property y¶
pygeosolve.plot module¶
Plotting.
pygeosolve.problem module¶
Constraint problems.
- class pygeosolve.problem.Problem[source]¶
Bases:
object- constrain_angle_between_lines(line_a, line_b, angle)[source]¶
Add a constraint on the angle between two lines.
- Parameters
- line_a, line_b
str The names of the lines to constrain.
- :class:`float`
The angle (in degrees) to target.
- line_a, line_b
- constrain_line_length(name, length)[source]¶
Add a constraint on the length of a line.
- Parameters
- name
str The name of the line to constrain.
- length
float The line length to target.
- name
- constrain_position(name)[source]¶
Fix the current position of a primitive.
- Parameters
- name
str The name of the primitive to fix.
- name
- error()[source]¶
Calculate the current free parameter values’ total error.
- Returns
floatThe total error.
- property free_params¶
Free parameter names in this problem.
- property free_values¶
- property points¶
- solve(**kwargs)[source]¶
Solve the problem.
This attempts to minimise the error function given the defined constraints. A successful minimisation results in the new, optimised parameter values being assigned.
- Returns
scipy.optimize.OptimizeResultThe optimisation result.
- Other Parameters
- kwargs
Keyword arguments supported by
scipy.optimize.basinhopping().
pygeosolve.util module¶
Utilities.