ZigZag#

class ZigZag#

Bases: object

A zig-zag polyline representation of a tangle.

The geometry is a list of polyline segments, each a list of complex points. We also store a “compass” rectangle (NW, SW, SE, NE) that indicates the bounding endpoints for the left/right/top/bottom boundary of the tangle.

__init__()#

Methods

__init__()

add_line(line)

Append a non-degenerate polyline to the zig-zag.

bounding_box(compass)

Return tight bounding coordinate for a given compass letter.

join()

Join polyline segments that share endpoints into longer polylines.

mirror()

Mirror through the y-axis.

move(dz)

Translate the entire zig-zag by complex offset dz.

reflect()

Reflect (mirror then rotate).

rotate()

Rotate once CCW (multiply coordinates by 1j).

set_compass(NW, SW, SE, NE)

Set the compass rectangle of the zig-zag.

smoothen()

Placeholder for point simplification (kept for compatibility).

split()

Split long nearly straight segments (used for smoothing heuristics).

Attributes

property N: complex#
property S: complex#
property W: float#
property E: float#
property height: float#
property width: float#
bounding_box(compass)#

Return tight bounding coordinate for a given compass letter.

Parameters:

compass (str)

Return type:

complex | float

add_line(line)#

Append a non-degenerate polyline to the zig-zag.

Parameters:

line (list[complex])

set_compass(NW, SW, SE, NE)#

Set the compass rectangle of the zig-zag.

Parameters:
  • NW (complex)

  • SW (complex)

  • SE (complex)

  • NE (complex)

mirror()#

Mirror through the y-axis.

rotate()#

Rotate once CCW (multiply coordinates by 1j).

reflect()#

Reflect (mirror then rotate).

move(dz)#

Translate the entire zig-zag by complex offset dz.

Parameters:

dz (complex)

join()#

Join polyline segments that share endpoints into longer polylines.

smoothen()#

Placeholder for point simplification (kept for compatibility).

split()#

Split long nearly straight segments (used for smoothing heuristics).