morphogen.models.pieces

The smooth pieces of the phases of structures made of spheres and segments.

The implicit function of a union of primitives is the smallest of their distances, min_i d_i: smooth where one primitive is the nearest, folded where two are as near. Its zero level set, the boundary of the union, has a sharp edge along the line where the surfaces of two overlapping primitives meet (the groove between two spheres, the line where two fibres cross). A function sampled on a grid cannot hold such an edge: a mesher that cuts the box by the zero of min_i d_i rounds it over a cell.

Each primitive alone is smooth. The primitives of a union are therefore grouped into pieces such that two primitives that overlap are never in the same piece — a colouring of the graph of their overlaps (colours()), periodic images included. The distance to a piece is smooth near its surface, the phase is the union of its pieces, and a mesher that cuts the box by the surface of each piece in turn gets every sharp edge as the line where two of its cuts meet (morphogen.mesh.conforming.conforming_mesh()). A coating of thickness t is the union of the same primitives with their radii increased by t, the core of a shell that of the primitives with their radii decreased: other pieces, coloured again since thicker primitives overlap more.

A structure gives its pieces by implicit_pieces(), in the order of the cuts: a point belongs to the phase of the first piece that holds it, or to the phase of what is left.

class morphogen.models.pieces.Piece(phase: int, union: object)[source]

Bases: object

A smooth piece of a phase: primitives that do not overlap (a union), and the phase of the points that it holds.

at(points, band: float) → ndarray[source]

The signed distance to the piece (negative inside) at points, clipped to [-band, band].

morphogen.models.pieces.overlaps(union, offset: float = 0.0, depth: float = 0.0) → ndarray[source]

The pairs of primitives of a union (spheres first, then segments) that enter each other by more than depth, their radii increased by offset; through the faces of a periodic box as well. Rows (i, j) with i < j.

morphogen.models.pieces.colours(n: int, pairs: ndarray) → ndarray[source]

A colour for each of n vertices of a graph such that the two vertices of each of its edges pairs differ: the vertices of largest degree first, each takes the smallest colour that its neighbours do not have (Welsh & Powell 1967).

morphogen.models.pieces.union_pieces(union, offset: float = 0.0, depth: float = 0.0) → list[source]

The pieces of a union of spheres and segments whose radii are increased by offset (decreased, if negative: the primitives that vanish are left out): unions of primitives that do not enter each other by more than depth, as few as the colouring finds.