Line#
- class Line(start: Point, end: Point, data: compas.geometry.Line | None = None, plane: ReferencePlane | Axonometry | None = None)[source]#
Bases:
objectThe primary drawing element.
A line connects two
Pointobjects.- Parameters:
start (Point) – The first point.
end (Point) – The second point.
data (compas.geometry.Line | None) – Optionally set the data on creation, usually handled by
draw_line().plane (ReferencePlane | Axonometry | None) – Optionally set the plane membership on creation, usually set by parent.
Methods
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
Create a new Line instance using the given start and end coordinates, interpreted as 3D (x-y-z) coordinates.
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
Compute the intersection with another line, assuming they lie on the same plane.
Get the plane keys in which line has no projection.
Get the plane keys in which line has a projection.
Project crurrent line on another plane.
Projection of a surface in axonometric picture plane out of its perpendicular lines.
Make a random line object, perpendicular to one of the coordinate planes.
Attributes
Methods#
- static Line.from_xy(start: tuple[float], end: tuple[float]) Line[source]#
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
- Parameters:
- Returns:
A new Line instance with the specified start and end points.
- Return type:
- static Line.from_xyz(start: tuple[float], end: tuple[float]) Line[source]#
Create a new Line instance using the given start and end coordinates, interpreted as 3D (x-y-z) coordinates.
- Parameters:
- Returns:
A new Line instance with the specified start and end points.
- Return type:
- static Line.from_yz(start: tuple[float], end: tuple[float]) Line[source]#
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
- Parameters:
- Returns:
A new Line instance with the specified start and end points.
- Return type:
- static Line.from_zx(start: tuple[float], end: tuple[float]) Line[source]#
Create a new Line instance using the given start and end coordinates, interpreted as 2D (x-y) coordinates.
- Parameters:
- Returns:
A new Line instance with the specified start and end points.
- Return type:
- Line.intersections_with_line(line: Line) compas.geometry.Point[source]#
Compute the intersection with another line, assuming they lie on the same plane.
- Parameters:
line (Line) – The other line.
- Return type:
- Line.not_on_projection_planes() list[str] | None[source]#
Get the plane keys in which line has no projection.
- Line.on_projection_planes() list[str] | None[source]#
Get the plane keys in which line has a projection.
- Line.project(distance: float | None = None, start_distance: float | None = None, end_distance: float | None = None, ref_plane_key: Literal['xy', 'yz', 'zx'] | None = None) Line[source]#
Project crurrent line on another plane.
The projection can be in both directions between one of the three reference planes and the axonometric picture plane.
>>> from axonometry import Axonometry, Point, Line >>> my_axo = Axonometry(10,15)
>>> xy_line = my_axo["xy"].draw_line(Line(Point(x=-18, y=6), Point(x=26, y=12))) >>> xy_line.project(distance=75) Line(Point(x=-18, y=6, z=75), Point(x=26, y=12, z=75)) # z added by projection
>>> xyz_line = my_axo.draw_line(Line(Point(x=6, y=9, z=44), Point(x=45, y=-5, z=9))) >>> xyz_line.project(ref_plane_key="yz") Line(Point(y=9, z=44), Point(y=-5, z=9))
- Parameters:
distance (float | None) – The missing third coordinate in order to project the line on the axonometric picture plane. This applies when the point to project is contained in a reference plane.
start_distance (float | None) – Specify a distinct
distancevalue for theLine.startprojection.end_distance (float | None) – Specify a distinct
distancevalue for theLine.endprojection.ref_plane_key (Literal['xy', 'yz', 'zx'] | None) – Specify the reference plane for the auxilary projection.
- Returns:
A new line.
- Return type:
Attributes#
- Line.plane: ReferencePlane | Axonometry#
The
Planeof which the line is in; set by parent.
- Line.projections: dict[Literal['xy', 'yz', 'zx', 'xyz'], Line | list[Line]]#
Collection of the lines’ projections; updated automatically.
- Line.key: Literal['xy', 'yz', 'zx', 'xyz']#
The lines’ coordinate system, i.e. plane membership.
- Line.data: compas.geometry.Line | None#
View plane coordinate system line.