Skip to content

show_circle_packings

pleat.intersecting_cylinders.show_circle_packings

Visualize the two dual circle packings underlying an intersecting-cylinders tiling.

An :mod:pleat.intersecting_cylinders crease pattern is built from a tiling whose face incircles are mutually tangential. Together with the vertex circles (centred at each original vertex and passing through the tangent points on the incident edges) this gives two interleaved circle packings whose circles touch pairwise at the edge tangent points.

:func:show_dual_circle_packings builds the ortho-Conway graph of the input tiling, repositions every edge-midpoint vertex to the actual tangent point, and styles the result so the two circle families are rendered as filled red (face incircles) and blue (vertex circles) discs.

build_dual_circle_packings

build_dual_circle_packings(
    G: "EuclideanPositionHEG",
) -> "EuclideanPositionHEG"

Return a styled ortho-graph representing the two dual circle packings.

The returned graph is a fresh copy: the input G is not modified. Every vertex carries a color_key and vertex_radius attribute; circles coming from original faces use red fill, circles coming from original vertices use blue fill, and the tangent-point vertices are drawn as small black dots. Halfedges are coloured black and have line_width set so that only the vertex circles are outlined.

Parameters:

Name Type Description Default
G 'EuclideanPositionHEG'

A 2D Euclidean tiling whose faces have well-defined incenters such that the corresponding incircles are mutually tangential at every edge.

required

Returns:

Type Description
'EuclideanPositionHEG'

A copy of the ortho-Conway graph of G with cosmetic attributes

'EuclideanPositionHEG'

set, ready to pass to :meth:HalfEdgeGraph.show.

Source code in pleat/intersecting_cylinders/show_circle_packings.py
def build_dual_circle_packings(G: "EuclideanPositionHEG") -> "EuclideanPositionHEG":
    """Return a styled ortho-graph representing the two dual circle packings.

    The returned graph is a fresh copy: the input ``G`` is not modified. Every
    vertex carries a ``color_key`` and ``vertex_radius`` attribute; circles
    coming from original faces use red fill, circles coming from original
    vertices use blue fill, and the tangent-point vertices are drawn as small
    black dots. Halfedges are coloured black and have ``line_width`` set so
    that only the vertex circles are outlined.

    Args:
        G: A 2D Euclidean tiling whose faces have well-defined incenters such
            that the corresponding incircles are mutually tangential at every
            edge.

    Returns:
        A copy of the ortho-Conway graph of ``G`` with cosmetic attributes
        set, ready to pass to :meth:`HalfEdgeGraph.show`.
    """
    G_ortho = _build_ortho_with_tangent_points(G)
    G_ortho.normalize_positions()

    for v in G_ortho.vertices.union(G_ortho.faces):
        pre = v.get("pre_conway")
        if isinstance(pre, half.Face):
            v["color_key"] = _FACE_COLOR
            v["vertex_radius"] = float(np.linalg.norm(v["pos"] - v.any_outgoing.dest["pos"]))
            for h in v.outgoing_iter():
                h["line_width"] = 0.0
                h.rev["line_width"] = 0.0
        elif isinstance(pre, half.Vertex):
            v["color_key"] = _VERTEX_COLOR
            v["vertex_radius"] = float(np.linalg.norm(v["pos"] - v.any_outgoing.dest["pos"]))
            for h in v.outgoing_iter():
                h["line_width"] = _VERTEX_CIRCLE_LINE_WIDTH
                h.rev["line_width"] = _VERTEX_CIRCLE_LINE_WIDTH
        else:
            v["vertex_radius"] = _TANGENT_RADIUS
            v["color_key"] = _TANGENT_COLOR

    for h in G_ortho.halfedges:
        h["color_key"] = _TANGENT_COLOR

    return G_ortho

show_dual_circle_packings

show_dual_circle_packings(
    G: "EuclideanPositionHEG", **show_kwargs: Any
) -> None

Render the two dual circle packings of a tiling.

This is a thin convenience wrapper around :func:build_dual_circle_packings that calls :meth:HalfEdgeGraph.show on the resulting styled graph with render_faces=False.

Parameters:

Name Type Description Default
G 'EuclideanPositionHEG'

A 2D Euclidean tiling -- see :func:build_dual_circle_packings for the requirements on G.

required
**show_kwargs Any

Forwarded to :meth:HalfEdgeGraph.show. render_faces defaults to False but can be overridden.

{}
Source code in pleat/intersecting_cylinders/show_circle_packings.py
def show_dual_circle_packings(G: "EuclideanPositionHEG", **show_kwargs: Any) -> None:
    """Render the two dual circle packings of a tiling.

    This is a thin convenience wrapper around :func:`build_dual_circle_packings`
    that calls :meth:`HalfEdgeGraph.show` on the resulting styled graph with
    ``render_faces=False``.

    Args:
        G: A 2D Euclidean tiling -- see :func:`build_dual_circle_packings` for
            the requirements on ``G``.
        **show_kwargs: Forwarded to :meth:`HalfEdgeGraph.show`. ``render_faces``
            defaults to ``False`` but can be overridden.
    """
    show_kwargs.setdefault("render_faces", False)
    G_ortho = build_dual_circle_packings(G)
    G_ortho.show(**show_kwargs)