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 = 0and the end point to- t = 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] | 
- Attributes:
- startcompas.geometry.Point
- The start point of the line. 
- endcompas.geometry.Point
- The end point of the line. 
- vectorcompas.geometry.Vector, read-only
- A vector pointing from start to end. 
- lengthfloat, read-only
- Compute the length of the curve. 
- directioncompas.geometry.Vector, read-only
- A unit vector parallel to the line vector. 
- midpointcompas.geometry.Point, read-only
- The midpoint between start and end. 
- framecompas.geometry.Frame, read-only
- The frame of the line. This is alsways the world XY frame. 
- transformationcompas.geometry.Transformation, read-only
- This is always the identity transformation. 
 
- start
 - Examples - >>> line = Line([0, 0, 0], [1, 1, 1]) >>> print(line.start) Point(x=0.000, y=0.000, z=0.000) >>> print(line.midpoint) Point(x=0.500, y=0.500, z=0.500) >>> line.length == line.vector.length True >>> print(line.direction) Vector(x=0.577, y=0.577, z=0.577) - Methods - Compute the closest point on the line to a given point. - Flip the direction of the line. - Return a new line with the direction flipped. - Construct a line from a point and a vector. - Construct a line from a point, a direction and a length. - Construct a point along the line at a fractional position. - Construct a point along the line at a distance from the end point. - Construct a point along the line at a distance from the start point. - 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. - Construct a parametric curve from a native curve geometry. - 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.