Line
- class compas.geometry.Line(p1, p2, **kwargs)[source]
Bases:
compas.geometry.primitives._primitive.PrimitiveA line is defined by two points.
- Parameters
p1 (point) – The first point.
p2 (point) – The second point.
- Attributes
data (dict) – The data representation of the line.
start (
compas.geometry.Point) – The first point of the line.end (
compas.geometry.Point) – The second point of the line.vector (
compas.geometry.Vector) – A vector pointing fromstarttoend.direction (
compas.geometry.Vector) – A unit vector pointing fromstarttoend.midpoint (
compas.geometry.Point) – A point half way betweenstartandend.length (float, read-only) – The length of the line segment between
startandend.
Examples
>>> line = Line([0, 0, 0], [1, 1, 1]) >>> line Line(Point(0.000, 0.000, 0.000), Point(1.000, 1.000, 1.000)) >>> line.start Point(0.000, 0.000, 0.000) >>> line.midpoint Point(0.500, 0.500, 0.500) >>> line.length == math.sqrt(1 + 1 + 1) True >>> line.direction Vector(0.577, 0.577, 0.577)Attributes
DATASCHEMAThe schema of the data of this object.
JSONSCHEMANAMEdataThe data dictionary that represents the line.
directionA unit vector pointing from start and end.
endThe end point of the line.
lengthThe length of the vector from start to end.
midpointThe midpoint between start and end.
startThe start point of the line.
vectorA vector pointing from start to end.
Inherited Attributes
JSONSCHEMAThe schema of the JSON representation of the data of this object.
dtypeThe type of the object in the form of a '2-level' import and a class name.
guidThe globally unique identifier of the object.
jsondefinitionsReusable schema definitions.
jsonstringThe representation of the object data in JSON format.
jsonvalidatorJSON schema validator for draft 7.
nameThe name of the object.
Methods
Construct a frame from a data dict.
A point between start and end at a specific normalized parameter.
Transform this line.
Transform a collection of
Lineobjects.Create a collection of transformed
Lineobjects.Inherited Methods
Make an independent copy of the data object.
Construct an object from serialized data contained in a JSON file.
Construct an object from serialized data contained in a JSON string.
Convert an object to its native data representation.
Serialize the data representation of an object to a JSON file.
Serialize the data representation of an object to a JSON string.
Returns a transformed copy of this geometry.
Validate the object's data against its data schema (self.DATASCHEMA).
Validate the object's data against its json schema (self.JSONSCHEMA).