Constraint

class compas_fd.constraints.Constraint

Bases: Data

Base class for all constraints.

Parameters:
geometrycompas.geometry.Geometry

The geometry of the constraint.

namestr, optional

The name of the constraint.

Attributes:
geometrycompas.geometry.Geometry

The geometry of the constraint.

locationcompas.geometry.Point

The location of the constrained vertex.

residualcompas.geometry.Vector

The residual vector at the constrained vertex.

tangentcompas.geometry.Vector

The tangent vector of the residual at the constrained vertex.

normalcompas.geometry.Vector

The normal vector of the residual at the constrained vertex.

paramfloat

The parameter of the closest point on the constraint geometry to the location of the constrained vertex.

Notes

The constraint class using a registration mechanism to determine the type of constraint object for a given constraint geometry. Therefore, this class is the main entry point for creating constraints.

Examples

>>> from compas.geometry import Line
>>> from compas_fd.constraints import Constraint
>>> line = Line([0, 0, 0], [1, 0, 0])
>>> constraint = Constraint(line)
>>> constraint
LineConstraint(Line(Point(x=0.0, y=0.0, z=0.0), Point(x=1.0, y=0.0, z=0.0)), name=None)

Methods

compute_normal

compute_param

compute_tangent

get_constraint_cls

project

register

update

update_location_at_param

Inherited Methods

ToString

Converts the instance to a string.

copy

Make an independent copy of the data object.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

validate_data

Validate the data against the object's data schema.