Skip to content
Projects

Booleans and transforms

The equations of simgeometry.operations, declared on the code that implements them and checked by the tests.

BooleanShape

classsource

A snapshot of a union, intersection, or difference of two shapes.

union
a∨b:ϕ=min⁡(ϕa,ϕb)a \lor b: \quad \phi = \min(\phi_a, \phi_b)
intersection
a∧b:ϕ=max⁡(ϕa,ϕb)a \land b: \quad \phi = \max(\phi_a, \phi_b)
difference
a∧¬b:ϕ=max⁡(ϕa,−ϕb)a \land \lnot b: \quad \phi = \max(\phi_a, -\phi_b)
Assumes
  • membership combines the operands' masks; a level set needs one on both operands
  • the combined level set is a bound on the distance, not the exact distance (level_set_exact is False)

PolarRepeat

classsource

count copies of a 3D shape rotated about an axis, evaluated as one.

fold
φ′=φ−k Δ,k=round⁡(φ/Δ),Δ=2πN\varphi' = \varphi - k\,\Delta, \quad k = \operatorname{round}(\varphi / \Delta), \quad \Delta = \frac{2\pi}{N}
level set
ϕN(p)=min⁡j∈{k−1,k,k+1}ϕ(R−jΔ p)\phi_N(p) = \min_{j \in \{k - 1, k, k + 1\}} \phi\big(R_{-j\Delta}\, p\big)
Assumes
  • NN copies of the source rotated about the axis by multiples of Δ\Delta; φ\varphi the point's angle about the axis from the reference direction (the unit vector normal to the axis closest to x)
  • the source lies within its sector ∣φ∣<Δ/2|\varphi| < \Delta / 2 (copies do not overlap), so membership is the source's at the point rotated into the first sector
  • the level set is the smallest over the point's sector and its two neighbours: a bound on the distance where the nearest copy is among them (copies away from the axis)

Section

classsource

A membership-preserving section, including holes and disconnected pieces.

plane
p=o+Bq,q=BT(p−o)p = o + B q, \qquad q = B^\mathsf{T}(p - o)
level set
ϕsection(q)=ϕ(o+Bq)\phi_\mathrm{section}(q) = \phi(o + B q)
Assumes
  • BB the orthonormal in-plane basis (columns), oo the plane origin; membership is the source's at o+Bqo + Bq
  • the source's level set on the plane only bounds the in-plane distance (level_set_exact is False)

TransformedShape

classsource

Independent affine image of a source, mapping p to matrix @ p + offset.

map
p↦Mp+o,p∈T(S)  ⟺  M−1(p−o)∈Sp \mapsto M p + o, \qquad p \in T(S) \iff M^{-1}(p - o) \in S
level set
ϕT(p)=σmin(M) ϕ(M−1(p−o))\phi_T(p) = \sigma_\mathrm{min}(M)\,\phi\big(M^{-1}(p - o)\big)
bound
∣M−1x−M−1y∣≤∣x−y∣σmin(M)|M^{-1}x - M^{-1}y| \le \frac{|x - y|}{\sigma_\mathrm{min}(M)}
normal
nT=M−Tn∣M−Tn∣n_T = \frac{M^{-T} n}{|M^{-T} n|}
Assumes
  • MM invertible and finite; σmin\sigma_\mathrm{min} its smallest singular value
  • the level set stays a bound on the distance; it is exact only for an exact source under a similarity (rigid motion or uniform scaling)