Skip to content

Lines & Segments

Line primitives for connecting points and creating geometric constructions.

API Reference

geolet.primitives.lines.api.Segment

Segment(p1: PointT, p2: PointT, *, label: str = '', label_dir: str = 'N', label_pos: float = 0.5, color: str = 'black', style: str = 'solid', width: float = 1.0, marks: int = 0) -> SegmentT

Create a line segment between two points.

Parameters:

Name Type Description Default
p1 PointT

First endpoint.

required
p2 PointT

Second endpoint.

required
label str

Display label for the segment (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.5
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0
marks int

Number of tick marks to draw on segment (for congruence).

0

Returns:

Type Description
SegmentT

A segment drawable satisfying SegmentT protocol.


geolet.primitives.lines.api.Line

Line(p1: PointT, p2: PointT, *, label: str = '', label_dir: str = 'N', label_pos: float = 0.0, color: str = 'black', style: str = 'solid', width: float = 1.0) -> LineT

Create an infinite line through two points.

Parameters:

Name Type Description Default
p1 PointT

First point defining the line.

required
p2 PointT

Second point defining the line.

required
label str

Display label for the line (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.0
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0

Returns:

Type Description
LineT

A line drawable satisfying LineT protocol.


geolet.primitives.lines.api.Triangle

Triangle(p1: PointT, p2: PointT, p3: PointT, *, color: str = 'black', style: str = 'solid', width: float = 1.0) -> TriangleT

Create a triangle defined by three vertices.

Automatically draws all three sides as segments. Provides methods to access triangle centers and circles.

Parameters:

Name Type Description Default
p1 PointT

First vertex.

required
p2 PointT

Second vertex.

required
p3 PointT

Third vertex.

required
color str

Asymptote color for all sides.

'black'
style str

Line style for all sides. One of: solid, dashed, dotted.

'solid'
width float

Line width for all sides.

1.0

Returns:

Type Description
TriangleT

A triangle drawable satisfying TriangleT protocol.


geolet.primitives.lines.api.PerpendicularLine

PerpendicularLine(point: PointT, to: SegmentT | LineT, *, label: str = '', label_dir: str = 'N', label_pos: float = 0.0, color: str = 'black', style: str = 'solid', width: float = 1.0) -> LineT

Create a line perpendicular to a line or segment through a point.

Parameters:

Name Type Description Default
point PointT

Point the perpendicular line passes through.

required
to SegmentT | LineT

The line or segment to be perpendicular to.

required
label str

Display label for the line (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.0
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0

Returns:

Type Description
LineT

A perpendicular line drawable.


geolet.primitives.lines.api.ParallelLine

ParallelLine(point: PointT, to: SegmentT | LineT, *, label: str = '', label_dir: str = 'N', label_pos: float = 0.0, color: str = 'black', style: str = 'solid', width: float = 1.0) -> LineT

Create a line parallel to another line through a point.

Parameters:

Name Type Description Default
point PointT

Point the parallel line passes through.

required
to SegmentT | LineT

The line to be parallel to (Line or Segment).

required
label str

Display label for the line (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.0
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0

Returns:

Type Description
LineT

A parallel line drawable.


geolet.primitives.lines.api.AngleBisector

AngleBisector(vertex: PointT, p1: PointT, p2: PointT, *, label: str = '', label_dir: str = 'N', label_pos: float = 0.0, color: str = 'black', style: str = 'solid', width: float = 1.0) -> LineT

Create the angle bisector at a vertex between two rays.

Creates the bisector of the angle formed at vertex by rays to p1 and p2.

Parameters:

Name Type Description Default
vertex PointT

The vertex of the angle.

required
p1 PointT

Point defining the first ray from vertex.

required
p2 PointT

Point defining the second ray from vertex.

required
label str

Display label for the line (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.0
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0

Returns:

Type Description
LineT

An angle bisector line drawable.


geolet.primitives.lines.api.Tangent

Tangent(point: PointT, circle: CircleT, *, index: int = 0, label: str = '', label_dir: str = 'N', label_pos: float = 0.0, color: str = 'black', style: str = 'solid', width: float = 1.0) -> LineT

Create a tangent line from an external point to a circle.

When the point is external to the circle, two tangent lines exist. Use index=0 for the first tangent and index=1 for the second.

Parameters:

Name Type Description Default
point PointT

External point from which tangent is drawn.

required
circle CircleT

The circle to draw tangent to.

required
index int

Which tangent line (0 or 1) when two exist.

0
label str

Display label for the line (empty string for no label).

''
label_dir str

Direction for label placement (N, NE, E, SE, S, SW, W, NW).

'N'
label_pos float

Relative position along path for label (0.0 = start, 1.0 = end).

0.0
color str

Asymptote color name (e.g. 'black', 'red', 'blue').

'black'
style str

Line style. One of: solid, dashed, dotted.

'solid'
width float

Line width in Asymptote units.

1.0

Returns:

Type Description
LineT

A tangent line drawable.

Example

O = Point("O", 0, 0) c = CircleWithRadius(O, 2) P = Point("P", 4, 0) t1 = Tangent(P, c, index=0, color="blue") t2 = Tangent(P, c, index=1, color="red")

Examples

Basic Segment

from geolet import Point, Segment, autofigure


@autofigure
def segment_example():
    A = Point("A", 0, 0, label_dir="SW")
    B = Point("B", 4, 0, label_dir="SE")

    Segment(A, B, label="c")

Triangle with Methods

from geolet import Point, Triangle, autofigure


@autofigure
def triangle_example():
    A = Point("A", 0, 0, label_dir="SW")
    B = Point("B", 6, 0, label_dir="SE")
    C = Point("C", 2, 4, label_dir="N")

    T = Triangle(A, B, C)

    # Access triangle centers via methods
    G = T.centroid(label="G", color="blue")
    H = T.orthocenter(label="H", color="red")

Perpendicular Line

from geolet import Point, Segment, PerpendicularLine, autofigure


@autofigure
def perpendicular_example():
    A = Point("A", 0, 0, label_dir="SW")
    B = Point("B", 4, 0, label_dir="SE")
    P = Point("P", 2, 2, label_dir="N")

    seg = Segment(A, B)
    PerpendicularLine(P, seg, style="dashed", color="blue")

Tangent Lines

from geolet import Point, CircleWithRadius, Tangent, autofigure


@autofigure
def tangent_example():
    O = Point("O", 0, 0)
    c = CircleWithRadius(O, 2)

    P = Point("P", 4, 0, label_dir="E")

    # Two tangent lines from external point
    Tangent(P, c, index=0, color="blue")
    Tangent(P, c, index=1, color="red")