Spiral layout¶
The Archimedean spiral: place units evenly by arc length along an outward spiral.
lexograph.layout.spiral.spiral_layout(n, *, turns=16.0, r0=1.0, r_max=10.0)
¶
Place n units evenly by arc length along an Archimedean spiral.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of units to place. |
required |
turns
|
float
|
How many full revolutions the spiral makes from |
16.0
|
r0
|
float
|
The starting radius (the innermost unit sits here). |
1.0
|
r_max
|
float
|
The outermost radius (the last unit sits near here). |
10.0
|
Returns:
| Type | Description |
|---|---|
Coords
|
An |
Coords
|
innermost unit outward. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Contract
- Returns exactly
nrows. - Radius increases monotonically from the first unit to the last.
- The output is deterministic in its inputs.
Examples:
>>> coords = spiral_layout(5, turns=2.0, r0=1.0, r_max=4.0)
>>> coords.shape
(5, 2)
>>> import numpy as np
>>> radii = np.hypot(coords[:, 0], coords[:, 1])
>>> bool(np.all(np.diff(radii) > 0))
True
Source code in lexograph/layout/spiral.py
lexograph.layout.spiral.tangent_angles(coords)
¶
Return the tangent direction (degrees) of an ordered path at each point.
Computed from the local gradient of the coordinates, this orients per-unit glyphs so they follow the curve (used to set the rotation of each mark on the punctuation spiral).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords
|
Coords
|
An |
required |
Returns:
| Type | Description |
|---|---|
FloatArray
|
A length- |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
>>> import numpy as np
>>> tangent_angles(np.array([[0.0, 0.0], [1.0, 0.0], [2.0, 0.0]])).tolist()
[0.0, 0.0, 0.0]