pynrose package
- class pynrose.Grid(origin: Vector, grid_size: Vector)
Bases:
objectA repeating grid of equal-size grid cells.
- cell(x: int, y: int)
Returns the (x, y)th grid cell.
- property grid_size
The size of each grid cell.
- property origin
The coordinate of the lower left corner of the (0, 0)th grid cell.
- class pynrose.GridCell(grid: Grid, x_multiple: int, y_multiple: int)
Bases:
objectAn individual grid cell.
- corners(margin=0.0)
Returns the 4 coordinates of the corners of the grid, with an optional margin added.
- Parameters:
margin – How much margin to add around the edges of the grid cell.
- property extent
The coordinate of the upper right corner of this grid cell.
- property grid
The grid that this grid cell is a part of.
- midpoint()
Returns the midpoint of the grid.
- property origin
The coordinate of the lower left corner of this grid cell.
- property x_multiple
The x multiple of this grid cell.
- property y_multiple
The y multiple of this grid cell.
- class pynrose.PentAngle(pentangle: int)
Bases:
objectA multiple of 360/5 degrees.
- cos(other: PentAngle | None = None) float
Returns the cos of this pentangle, or of the angle between this pentangle and another pentangle.
- degrees()
The angle of this pentangle in degrees.
- inverse_cos(other: PentAngle) float
Returns the inverse of the cos of the angle between this pentangle and another pentangle.
- inverse_sin(other: PentAngle) float
Returns the inverse of the sin of the angle between this pentangle and another pentangle.
- property pentangle
The multiple of 360/5 degrees that this pentangle represents.
- radians()
The angle of this pentangle in radians.
- class pynrose.PentAngles
Bases:
objectA convenience class for
- static all()
Returns a tuple of all PentAngles in order.
- static others(pent_angle: PentAngle)
Returns the other 4 PentAngles, excluding the given one, in order.
- static pentangle(pentangle: int)
Returns a PentAngle object for the given pentangle.
- class pynrose.Rhombus(strip1: Strip, strip2: Strip, lattice_coords: Tuple[int, ...])
Bases:
objectRepresents a single Rhombus.
- contains_point(point: Vector)
Returns whether this rhombus contains the given point.
Will return true for any point on the interior, any point on one of the edges, or any of the vertices.
- property lattice_coords
The lattice coordinate of the “maximal” vertex.
- property midpoint
Returns the midpoint of this rhombus.
- ordered_strips()
Returns the 2 intersection Strips that define this rhombus, in order of pentangle.
- property strip1
One of the pair of intersecting strips that defines this rhombus.
- property strip2
The other of the pair of intersecting strips that defines this rhombus.
- type()
Returns the RhombusType of this rhombus.
- vertices()
Returns the 4 vertices of this rhombus.
- class pynrose.Strip(family: StripFamily, multiple: int)
Bases:
objectRepresents a single string of rhombii in de Bruijn’s method
- property family
The StripFamily this Strip is associated with.
- intersection(other: Strip)
Returns the coordinates of the intersection between this Strip and the given Strip.
- Parameters:
other – The strip to find the intersection with.
- Returns:
The coordinates in pentagrid space of the intersection between this strip and the given strip, or None if the strips are parallel.
- intersection_distance_from_point(other: Strip)
Returns the distance in pentagrid space from the strip’s origin to the intersection with the given strip.
- Parameters:
other – The strip to find the intersection with. Must not be from the same family/parallel.
- property multiple
The multiple of this Strip.
- origin()
Returns the origin of the strip, which is an arbitrary point that lies on the strip.
- rhombii(start_distance: float, forward: bool)
Infinitely iterates over the rhombii in this Strip.
- Parameters:
start_distance – The distance in pentagrid space from this Strip’s origin to start iterating.
forward – The direction to iterate.
- rhombus(target_distance: float)
Returns the rhombus nearest the given distance from this Strip’s origin.
This finds the intersection closest to the point that is the given distance from this Strip’s origin, and returns the associated rhombus.
- Parameters:
target_distance – The distance from the Strip’s origin in pentagrid space.
- rhombus_at_intersection(other: Strip)
Returns the Rhombus represented by the intersection of this Strip and the given Strip.
- Parameters:
other – The Strip to find the intersection with. Must not be from the same StripFamily as this Strip (i.e. not parallel with this Strip).
- two_points()
Returns two arbitrary, non-equal points on the strip as vectors from the origin.
- class pynrose.StripFamily(tiling: Tiling, offset: float, pentangle: PentAngle)
Bases:
objectRepresents 1 of the 5 families of strips of rhombii in de Bruijn’s method.
- property offset
The offset in pentagrid space for this family.
- offset_direction() Vector
Returns a unit vector perpendicular to the strips from this family, in the positive direction.
For example, if multiple 0 is a strip that runs vertically at x=0, and multiple 1 is a vertical strip at x=1, then offset_direction will be (1, 0).
- origin()
Returns the origin of this family.
- property pentangle
The pentangle for this family.
- strip(multiple: int)
Returns the strip at the given multiple.
- strips_near_point(point: Vector)
Returns 1 or 2 strips from this family that are near the given point.
The returned strips are ones that could potentially (but may not) contain the rhombus at the given point.
- property tiling
The Tiling that this StripFamily is associated with.
- class pynrose.Tiling(offsets: Sequence[float] | None = None, rnd: Random | None = None, check_offsets: bool = True)
Bases:
objectRepresents a P3 penrose tiling, generated by de Bruijn’s method
- rhombii(grid_cell: GridCell)
Returns all rhombii in the given grid cell.
All rhombii whose midpoint lies in the given grid cell will be returned. Parts of some of these rhombii will extend outside the grid cell.
A rhombus is contained by exactly one grid cell. If the midpoint lies on a grid cell edge or corner, the grid cell with the higher x and/or y indices “wins”.
- Parameters:
grid_cell – The grid cell to get the rhombii within.
- rhombus_at_point(point: Vector)
Returns the Rhombus that contains the given point.
- Parameters:
point – The point to find the containing Rhombus of.
- rhombus_edges(grid_cell: GridCell)
Returns all distinct rhombus edges of rhombii in the given grid cell.
All edges will be returned for every rhombus whose midpoint is contained in the grid cell. Some of the returned edges will fall outside the grid cell.
A rhombus is contained by exactly one grid cell. If the midpoint lies on a grid cell edge or corner, the grid cell with the higher x and/or y indices “wins”.
- Parameters:
grid_cell – The grid cell to find the rhombus edges within.
- Returns:
An iterable of (RhombusVertex, RhombusVertex) tuples.