pymead.core.gcs.GCS#
- class GCS[source]#
Bases:
DiGraphA Geometric Constraint Solver (GCS) used to maintain constraints between points in pymead, implemented using the directed graph class in
networkx. Instances of this class should not normally be created directly; the geometry collection creates objects of this class whenGeometryCollection.add_constraintis called.This constraint solver, while not powerful enough to handle arbitrary systems of equations, is nevertheless sufficient for handling many common types of constraints needed for airfoil systems. The constraints are solved using a graph-constructive approach and maintained using simple rigid body transformations. These transformations occur for a given set of points when the parameter value of a constraint “upstream” of this set of points is modified. All the points downstream of this constraint are handled as a rigid body (even if they are not fully constrained as such) to preserve each of the relative constraints.
The primary constraints in pymead are distance constraints and relative angle constraints (with specialized options for perpendicular and antiparallel constraints). The angle constraints are formed between three points (start, vertex, and end). Two other special kinds of constraints, symmetry constraints and radius of curvature constraints, are solved following the rigid body transformation.
Methods
add_constraint(constraint)Adds a geometric constraint to the graph.
add_point(point)Adds a point (node) to the graph (and to the
"points"attribute).check_constraint_for_duplicates(geo_con)Wrapper function for
_check_distance_constraint_for_duplicatesand_check_angle_constraint_for_duplicatesthat applies the duplicate check depending on the constraint type.move_root(new_root)Moves the root status of a constraint cluster from one point to a new point
remove_constraint(constraint)Removes a geometric constraint from the graph.
remove_point(point)Removes a point (node) from the graph (and from the
"points"attribute).rotate_cluster(rotation_handle[, ...])Rotates the constraint cluster defined by the input rotation handle by either the angle specified by
new_rotation_angleor by the angle difference specified by the angle between the cluster root and (new_rotation_handle_x,new_rotation_handle_y) and the initial angle between the root and rotation handle.solve(source)Wrapper around the difference constraint solution methods that applies a solution based on the input constraint type.
solve_other_constraints(points)Solves all radius of curvature and symmetry constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
solve_roc_constraint(constraint)Solves a radius of curvature constraint by translating the \(G^2\) points along a fixed angle.
solve_roc_constraints(points)Solves all radius of curvature constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
solve_symmetry_constraint(constraint)Solves a symmetry constraint by modifying the position of the target point to be the mirror of the tool point about the line defined by the first two points in the constraint.
solve_symmetry_constraints(points)Solves all symmetry constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
translate_cluster(root, dx, dy)Translate the constraint cluster (defined by the root point) by a given \(\Delta x\) and \(\Delta y\).
update_canvas_items(points_solved)Updates the visual representation in the airfoil canvas of all geometric objects modified by the process of solving the constraint system.
Attributes
- add_constraint(constraint: GeoCon)[source]#
Adds a geometric constraint to the graph.
Warning
This method should generally not be called directly. Instead, the
GeometryCollection.add_constraintmethod that calls this method should be used.- Parameters:
constraint (GeoCon) – Geometric constraint to add
- add_point(point: Point)[source]#
Adds a point (node) to the graph (and to the
"points"attribute). Also assigns this graph to the point.- Parameters:
point (Point) – Point to add
- check_constraint_for_duplicates(geo_con: GeoCon)[source]#
Wrapper function for
_check_distance_constraint_for_duplicatesand_check_angle_constraint_for_duplicatesthat applies the duplicate check depending on the constraint type.- Parameters:
geo_con (GeoCon) – Geometric constraint being added to the graph
- move_root(new_root: Point)[source]#
Moves the root status of a constraint cluster from one point to a new point
- Parameters:
new_root (Point) – Node that will be elevated to root status. The old root is discovered from this new root and the root status of the old root is removed.
- remove_constraint(constraint: GeoCon)[source]#
Removes a geometric constraint from the graph.
Warning
This method should generally not be called directly. Instead, the
GeometryCollection.remove_pymead_objmethod that calls this method should be used.- Parameters:
constraint (GeoCon) – Geometric constraint to remove
- remove_point(point: Point)[source]#
Removes a point (node) from the graph (and from the
"points"attribute).- Parameters:
point (Point) – Point to remove
- rotate_cluster(rotation_handle: ~pymead.core.point.Point, new_rotation_handle_x: float | None = None, new_rotation_handle_y: float | None = None, new_rotation_angle: float | None = None) -> (typing.List[pymead.core.point.Point], <class 'pymead.core.point.Point'>)[source]#
Rotates the constraint cluster defined by the input rotation handle by either the angle specified by
new_rotation_angleor by the angle difference specified by the angle between the cluster root and (new_rotation_handle_x,new_rotation_handle_y) and the initial angle between the root and rotation handle.- Parameters:
rotation_handle (Point) – Rotation handle of the constraint cluster
new_rotation_handle_x (float or None) – \(x\)-location of the new rotation handle point position. Default:
Nonenew_rotation_handle_y (float or None) – \(y\)-location of the new rotation handle point position. Default:
Nonenew_rotation_angle (float or None) – New rotation angle for the cluster. Can only be specified if
new_rotation_handle_xandnew_rotation_handle_yare not specified.
- Returns:
List of points solved after rotating the constraint cluster and the root point of the constraint cluster
- Return type:
- solve(source: GeoCon) List[Point][source]#
Wrapper around the difference constraint solution methods that applies a solution based on the input constraint type.
- solve_other_constraints(points: List[Point]) List[Point][source]#
Solves all radius of curvature and symmetry constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
- static solve_roc_constraint(constraint: ROCurvatureConstraint) List[Point][source]#
Solves a radius of curvature constraint by translating the \(G^2\) points along a fixed angle.
- Parameters:
constraint (ROCurvatureConstraint) – Radius of curvature constraint to solve
- Returns:
The child nodes of the radius of curvature constraint (the \(G^1\) and \(G^2\) points)
- Return type:
- solve_roc_constraints(points: List[Point]) List[Point][source]#
Solves all radius of curvature constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
- solve_symmetry_constraint(constraint: SymmetryConstraint) List[Point][source]#
Solves a symmetry constraint by modifying the position of the target point to be the mirror of the tool point about the line defined by the first two points in the constraint.
- Parameters:
constraint (SymmetryConstraint) – The symmetry constraint to solve
- Returns:
The child nodes of the symmetry constraint (the line-defining points, the tool point, and the target point)
- Return type:
- solve_symmetry_constraints(points: List[Point]) List[Point][source]#
Solves all symmetry constraints associated with a list of points that was modified in some way, either by direct user input or indirectly via constraint solving.
- translate_cluster(root: Point, dx: float, dy: float) List[Point][source]#
Translate the constraint cluster (defined by the root point) by a given \(\Delta x\) and \(\Delta y\).
- Parameters:
- Returns:
List of points solved during the solution process of constraints attached to the points that were translated
- Return type: