Line
- class compas.geometry.Line[source]
Bases:
Curve
A line is a curve defined by two points.
The first point is the start point of the line. The second point is the end point of the line. The vector between the two points defines the direction of the line. The length of the vector is the length of the line. The direction vector is the unit vector of the vector between start and end. The parameterisation of the line is such that the start point corresponds to
t = 0
and the end point tot = 1
.The coordinate system of a line is always the world coordinate system (WCS). Transformation of a line is performed by transforming the start and end point.
- Parameters:
- start[float, float, float] |
compas.geometry.Point
The first point.
- end[float, float, float] |
compas.geometry.Point
The second point.
- namestr, optional
The name of the line.
- start[float, float, float] |
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(line.dx **2 + line.dy **2 + line.dz **2) True >>> line.direction Vector(0.577, 0.577, 0.577)
- Attributes:
- start
compas.geometry.Point
The start point of the line.
- end
compas.geometry.Point
The end point of the line.
- vector
compas.geometry.Vector
, read-only A vector pointing from start to end.
length
float, read-onlyCompute the length of the curve.
- direction
compas.geometry.Vector
, read-only A unit vector parallel to the line vector.
- midpoint
compas.geometry.Point
, read-only The midpoint between start and end.
- frame
compas.geometry.Frame
, read-only The frame of the line. This is alsways the world XY frame.
- transformation
compas.geometry.Transformation
, read-only This is always the identity transformation.
- start
Methods
Compute the closest point on the line to a given point.
Construct a line from a point and a vector.
Construct a line from a point, a direction and a length.
Construct a point at a specific location along the line.
Transform this line.
Inherited Methods
Converts the instance to a string.
Compute the axis-aligned bounding box of the curve.
Compute the axis-aligned bounding box of the geometry.
Compute the oriented bounding box of the geometry.
Make an independent copy of the data object.
Compute the curvature vector of the curve at a parameter.
Compute the curve parameters that divide the curve into a specific number of equal length segments.
Compute the curve parameters that divide the curve into segments of specified length.
Compute the local frame of the curve at a parameter.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Load a curve from an OBJ file.
Load a curve from a STP file.
Compute the normal of the curve at a parameter.
Reverse the parametrisation of the curve.
Reverse a copy of the curve.
Rotate the geometry.
Returns a rotated copy of this geometry.
Scale the geometry.
Returns a scaled copy of this geometry.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Compute the tangent vector of the curve at a parameter.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Write the curve geometry to an OBJ file.
Convert the curve to a list of points.
Convert the curve to a polygon.
Convert the curve to a polyline.
Write the curve geometry to a STP file.
Returns a transformed copy of this geometry.
Translate the geometry.
Returns a translated copy of this geometry.
Validate the data against the object's data schema.