Skip to content

Reflections

Reflect points over other points or lines.

API Reference

geolet.primitives.reflections.api.Reflect

Reflect(point: PointT, over: PointT | LineT | SegmentT, *, label: str = '', label_dir: str = 'NE', color: str = 'black') -> ReflectedPoint

Reflect a point over another point or a line/segment.

For point reflection: computes symmetric point (2*center - point). For line/segment reflection: reflects point across the line.

Parameters:

Name Type Description Default
point PointT

The point to reflect.

required
over PointT | LineT | SegmentT

The object to reflect over. Can be: - PointT: for point/central reflection - LineT/SegmentT: for line/axial reflection

required
label str

Display name for the reflected point. Omit for hidden.

''
label_dir str

Direction to place label relative to point.

'NE'
color str

Asymptote color name.

'black'

Returns:

Type Description
ReflectedPoint

A reflected point drawable.

Examples

Reflect Over a Point

from geolet import Point, Segment, Reflect, autofigure


@autofigure
def reflect_over_point():
    A = Point("A", 1, 2, label_dir="NW")
    O = Point("O", 2, 1, label_dir="S")

    # A' is the point such that O is the midpoint of AA'
    A_prime = Reflect(A, O, label="A'", label_dir="SE")

    Segment(A, A_prime, style="dashed", color="gray")

Reflect Over a Segment

from geolet import Point, Segment, Reflect, autofigure


@autofigure
def reflect_over_segment():
    # Mirror line
    M1 = Point("", 0, 0)
    M2 = Point("", 4, 0)
    mirror = Segment(M1, M2, color="blue")

    # Original point
    P = Point("P", 1, 2, label_dir="N")

    # Reflected point
    P_prime = Reflect(P, mirror, label="P'", label_dir="S")

    # Connect with dashed line
    Segment(P, P_prime, style="dashed", color="gray")

Reflect Over a Line

from geolet import Point, Line, Segment, Reflect, autofigure


@autofigure
def reflect_over_line():
    # Diagonal mirror line
    A = Point("", 0, 0)
    B = Point("", 3, 3)
    mirror = Line(A, B, color="blue", style="dashed")

    # Original triangle
    P = Point("P", 1, 0, label_dir="S")
    Q = Point("Q", 3, 0, label_dir="S")
    R = Point("R", 2, 1, label_dir="E")

    Segment(P, Q)
    Segment(Q, R)
    Segment(R, P)

    # Reflected triangle
    P_r = Reflect(P, mirror, label="P'", label_dir="W")
    Q_r = Reflect(Q, mirror, label="Q'", label_dir="N")
    R_r = Reflect(R, mirror, label="R'", label_dir="N")

    Segment(P_r, Q_r, color="red")
    Segment(Q_r, R_r, color="red")
    Segment(R_r, P_r, color="red")