Algorithm Search⌘K

Data structurecore

Sweep representation of solids

Also called swept solid representation, extrusion and revolution solids.

Represents a solid by a planar profile and a motion, as in extrusions and revolutions, and decides membership as a union over the sweep parameter.

Time
O(n) worst
Space
Θ(n) extra
Where
n = the number of vertices of the profile polygon

A sweep representation describes a solid by a set XX and a motion M(t)M(t), t∈[0,1]t \in [0, 1]: the solid is every point that XX occupies at some time. The two common cases are the extrusion, where a plane profile moves along a straight vector, and the revolution, where a profile in a half-plane turns a full circle about an axis. A shaft, a washer, a bolt head and a pocket outline are all of this kind, and every mechanical CAD system starts a part from such sweeps. The representation is very small and close to the way people draw, but it is not closed under Boolean operations: the union of two extrusions in different directions is not an extrusion. So a modeler stores a sweep as a primitive of a CSG tree or converts it to a B-rep. This page gives the data structure for extrusions and full revolutions of a simple polygon, and an exact classification of a point as inside, on the boundary of or outside the solid.

In plain words

Draw a shape on paper, then imagine pulling it straight up out of the paper, maybe at a slant. The paper shape leaves a trail, and the trail is a solid. That is an extrusion. Or stand the drawing up next to a pole and spin it once around the pole, like a lathe. The trail is a round solid, such as a ring or a cup. That is a revolution.

To ask if a point is in the trail, ask the reverse question: where was the drawing when it passed through this point? For an extrusion, the height of the point gives the moment, so slide the point back and test it against the drawing. For a revolution, turn the point back into the plane of the drawing and test it there. A point on the pole needs one more look.

The abstract type

A sweep is a pair (X,M)(X, M), where XX is a bounded set and M(t)M(t) is a rigid motion or an affine map for each tt in a parameter interval II. Its solid is the union over the parameter:

Sw(X,M)=⋃t∈IM(t)X,p∈Sw(X,M)  ⟺  ∃ t∈I:M(t)−1p∈X.\mathrm{Sw}(X, M) = \bigcup_{t \in I} M(t) X, \qquad p \in \mathrm{Sw}(X, M) \iff \exists\, t \in I : M(t)^{-1} p \in X.

The general problem of computing this union for any solid and any path is the swept volume problem. This page uses the two cases that Requicha's survey of 1980 calls translational and rotational sweeps:

  • Extrusion. XX is a simple polygon in the plane z=0z = 0, d=(dx,dy,dz)d = (d_x, d_y, d_z) is a vector with dz≠0d_z \neq 0, I=[0,1]I = [0, 1] and M(t)x=x+tdM(t) x = x + t d. The solid is a prism, upright if dx=dy=0d_x = d_y = 0 and slanted if not.
  • Revolution. XX is a simple polygon in the half-plane {(r,z):r≥0}\{(r, z) : r \ge 0\}, placed in space as the half-plane y=0y = 0, x≥0x \ge 0. I=[0,2π]I = [0, 2\pi] and M(θ)M(\theta) turns by θ\theta about the zz axis. The solid is the set of points (x,y,z)(x, y, z) with (x2+y2,z)∈X(\sqrt{x^2 + y^2}, z) \in X.

The operations are CLASSIFY(SS, pp), which returns IN, ON or OUT for a point pp with rational coordinates, VOLUME(SS), and CHECK(SS), which tests that the stored data give an r-set.

Representation

An extrusion stores the vertex list of XX, in either orientation, and the three numbers of dd. A revolution stores the vertex list of XX in (r,z)(r, z) coordinates. All coordinates are integers or fractions, so that every test below is exact.

The representation is valid, that is the solid is an r-set, under these conditions, which CHECK tests in O(n2)O(n^2) time:

  • XX is a simple polygon: at least three vertices, nonzero area, and no two edges that meet except neighbours at their common vertex.
  • For an extrusion, dz≠0d_z \neq 0. If dz=0d_z = 0, the profile slides in its own plane and the result is flat, with no volume.
  • For a revolution, every vertex has r≥0r \ge 0. A profile that crosses the axis sweeps some points twice, and the part on the far side is not a mirror image of the near side, so the stored data do not describe the solid that the user drew.

The representation is unambiguous: a pair (X,d)(X, d) or a profile XX gives one solid. It is not unique: the same prism is the extrusion of its bottom face along dd or of its top face along −d-d, and the same polygon has many vertex lists. In a scheme that also allows curved profiles, a cylinder is the extrusion of a disk and also the revolution of a rectangle.

Operations

The point p=(px,py,pz)p = (p_x, p_y, p_z) has rational coordinates. CLASSIFY-PROFILE(XX, qq) is the classification of a point of the plane against a closed polygon as IN, ON or OUT, as on the point in polygon page, with the even-odd crossing rule for IN and OUT and an exact test of whether qq lies on an edge.

  1. CLASSIFY-EXTRUSION(X, d, p)
  2. 1t ← p_z / d_z ▷ the only time at which the plane of X passes through p
  3. 2if t < 0 or t > 1 then return OUT
  4. 3q ← (p_x − t·d_x, p_y − t·d_y) ▷ p moved back to time 0
  5. 4c ← CLASSIFY-PROFILE(X, q)
  6. 5if c ≠ OUT and (t = 0 or t = 1) then return ON ▷ bottom or top face
  7. 6return c
  8. CLASSIFY-REVOLUTION(X, p)
  9. 7s ← p_x² + p_y² ▷ the square of the distance to the axis
  10. 8c ← CLASSIFY-PROFILE(X, (√s, p_z)), comparing √s with each rational number by squares
  11. 9if s > 0 or c = OUT then return c
  12. 10if the edges of X on the axis r = 0 contain (0, p_z) and reach above and below it then return IN
  13. 11return ON

Line L8 never computes s\sqrt{s}. The crossing rule needs only two kinds of test: whether the point is left or right of the crossing rcr_c of an edge with the line z=pzz = p_z, and whether it lies on a horizontal edge between two rational ends. Both compare s\sqrt{s} with a rational number qq, and s<q\sqrt{s} < q holds exactly when q>0q > 0 and s<q2s < q^2. So all signs are computed with integers and fractions, as the orientation test page asks for every geometric predicate.

The volumes follow from Cavalieri's principle and from Pappus's centroid theorem:

  1. VOLUME(S)
  2. V1 if S is an extrusion then return |area(X)| · |d_z|
  3. V2 m ← |Σ_i (r_i + r_{i+1}) (r_i z_{i+1} − r_{i+1} z_i)| / 6 ▷ the first moment of X about the axis
  4. V3 return 2π · m

Here (ri,zi)(r_i, z_i) are the vertices of XX in order, with indices taken modulo nn. Line V2 is the polygon form of ∬Xr dA\iint_X r \, dA; Pappus's theorem says that the volume of the revolution is 2π2\pi times this moment, the area of XX times the length of the circle traced by its centroid.

Example

Take the square XX with corners (0,0),(2,0),(2,2),(0,2)(0,0), (2,0), (2,2), (0,2) and the slanted vector d=(1,0,3)d = (1, 0, 3). The prism has volume 4⋅3=124 \cdot 3 = 12.

pp L1: tt L3: qq L4: cc result
(2,1,3/2)(2, 1, 3/2) 1/21/2 (3/2,1)(3/2, 1) IN IN
(3,1,3)(3, 1, 3) 11 (2,1)(2, 1) ON ON at L5
(1/5,1,3/2)(1/5, 1, 3/2) 1/21/2 (−3/10,1)(-3/10, 1) OUT OUT
(1,1,0)(1, 1, 0) 00 (1,1)(1, 1) IN ON at L5, bottom face
(1,1,−1)(1, 1, -1) −1/3-1/3 OUT at L2

Now revolve two profiles: the rectangle R1R_1 with r∈[1,2]r \in [1, 2], z∈[0,1]z \in [0, 1], which gives a ring, and the rectangle R2R_2 with r∈[0,2]r \in [0, 2], z∈[0,1]z \in [0, 1], which gives a cylinder.

profile pp L7: ss L8: cc result
R1R_1 (1,1,1/2)(1, 1, 1/2) 22 IN, since 1<2<21 < \sqrt 2 < 2 IN
R1R_1 (3/5,4/5,1/2)(3/5, 4/5, 1/2) 11 ON, on the edge r=1r = 1 ON
R1R_1 (0,0,1/2)(0, 0, 1/2) 00 OUT OUT
R2R_2 (0,0,1/2)(0, 0, 1/2) 00 ON, on the edge r=0r = 0 IN at L10
R2R_2 (0,0,1)(0, 0, 1) 00 ON, at a corner ON at L11
R2R_2 (1,1,1)(1, 1, 1) 22 ON, on the top edge, 0≤2≤20 \le \sqrt 2 \le 2 ON
R2R_2 (2,1,1/2)(2, 1, 1/2) 55 OUT, since 5>2\sqrt 5 > 2 OUT

The point (0,0,1/2)(0, 0, 1/2) is on the boundary of the profile R2R_2 but in the interior of the cylinder: the edge on the axis is glued to itself by the full turn. That is why lines L10 and L11 exist. For the volumes, V2 gives m=3/2m = 3/2 for R1R_1, so the ring has volume 3π3\pi, which is π(22−12)⋅1\pi(2^2 - 1^2) \cdot 1. For R2R_2 it gives m=2m = 2 and the volume 4π4\pi. The triangle with corners (0,0),(1,0),(0,1)(0, 0), (1, 0), (0, 1) revolves to a cone of volume π/3\pi/3.

Correctness

By the definition of the sweep, pp is in the solid exactly when some parameter value takes pp back into XX. For an extrusion, M(t)−1p=p−tdM(t)^{-1} p = p - t d lies in the plane z=0z = 0 only for t=pz/dzt = p_z / d_z, so there is one candidate time, and lines L1 to L4 test it. The map (x,y,t)↦(x+tdx,y+tdy,tdz)(x, y, t) \mapsto (x + t d_x, y + t d_y, t d_z) is an affine bijection from X×[0,1]X \times [0, 1] onto the solid, and an affine bijection keeps interiors, so pp is interior exactly when qq is interior to XX and 0<t<10 < t < 1. This gives line L5. For a revolution, the turn that brings pp into the half-plane of XX brings it to (s,0,pz)(\sqrt{s}, 0, p_z), for any angle if pp is on the axis. Off the axis, the map from (r,θ,z)(r, \theta, z) to space is a local diffeomorphism, so interior and boundary points of XX give interior and boundary points of the solid. On the axis, a small ball around pp is in the solid exactly when a small half-disk around (0,pz)(0, p_z) is in XX, which is the test of line L10. The full proof is in the proof file.

The tests check CLASSIFY against the definition. The oracle takes a finite sample of the sweep parameter, the times k/20k/20 for extrusions and 20 rational rotations from Pythagorean triples and quarter turns for revolutions, and tests whether M(t)−1pM(t)^{-1}p is in XX for some sample, with a winding number test that is independent of the crossing rule of the code. The test points are built so that their own parameter is in the sample, so the sampled union gives the exact answer for them. IN and ON are checked by small probes around the point in all lattice directions up to 8, at distance 1/10001/1000, and by probes along dd or along the circle. Points with an irrational radius s\sqrt s are checked against floating-point classification when they are more than 10−610^{-6} from the profile boundary, and the volumes against a grid count.

Proof: Point classification against extrusions and full revolutions of a simple polygon is exactfull

We use the pseudocode of the page. XX is a closed region bounded by a simple polygon with rational vertices, and CLASSIFY-PROFILE(XX, qq) returns IN for q∈int⁡Xq \in \operatorname{int} X, ON for q∈∂Xq \in \partial X and OUT otherwise. This is the correctness of the crossing rule with an exact on-edge test, proved on the point in polygon page; the only new point is that the first coordinate may be s\sqrt{s}, which Lemma 4 handles. Interior and boundary are taken in R2\mathbb{R}^2 for XX and in R3\mathbb{R}^3 for the solid.

Lemma 1 (membership is a union over the parameter). For any set XX, any family of bijections M(t)M(t) of space and any parameter set II, p∈⋃t∈IM(t)Xp \in \bigcup_{t \in I} M(t) X exactly when M(t)−1p∈XM(t)^{-1} p \in X for some t∈It \in I.

Proof. p∈M(t)Xp \in M(t) X means p=M(t)xp = M(t) x for some x∈Xx \in X, that is x=M(t)−1p∈Xx = M(t)^{-1} p \in X. A point is in a union exactly when it is in one of the sets. □\square

Lemma 2 (extrusion). Let dz≠0d_z \neq 0 and E=⋃t∈[0,1](X×{0}+td)E = \bigcup_{t \in [0,1]} (X \times \{0\} + t d). Then p∈Ep \in E exactly when t∗=pz/dz∈[0,1]t^* = p_z / d_z \in [0, 1] and q=(px−t∗dx,py−t∗dy)∈Xq = (p_x - t^* d_x, p_y - t^* d_y) \in X. Further, p∈int⁡Ep \in \operatorname{int} E exactly when 0<t∗<10 < t^* < 1 and q∈int⁡Xq \in \operatorname{int} X.

Proof. By Lemma 1, p∈Ep \in E exactly when p−td∈X×{0}p - t d \in X \times \{0\} for some t∈[0,1]t \in [0, 1]. The third coordinate of p−tdp - t d is pz−tdzp_z - t d_z, which is 00 only for t=t∗t = t^*, and then the first two coordinates are qq. For the interior, let A(x,y,t)=(x+tdx,y+tdy,tdz)A(x, y, t) = (x + t d_x, y + t d_y, t d_z). It is linear with determinant dz≠0d_z \neq 0, so it is a homeomorphism of R3\mathbb{R}^3, and E=A(X×[0,1])E = A(X \times [0, 1]). A homeomorphism of the whole space maps the interior of a set onto the interior of its image, so int⁡E=A(int⁡(X×[0,1]))=A(int⁡X×(0,1))\operatorname{int} E = A(\operatorname{int}(X \times [0,1])) = A(\operatorname{int} X \times (0, 1)). Since A−1p=(q,t∗)A^{-1} p = (q, t^*), the claim follows. □\square

Lemma 3 (revolution). Let X⊂{(r,z):r≥0}X \subset \{(r, z) : r \ge 0\} and let VV be the set of points (x,y,z)(x, y, z) with (x2+y2,z)∈X(\sqrt{x^2 + y^2}, z) \in X. This is the union over θ∈[0,2π]\theta \in [0, 2\pi] of the turns of {(r,0,z):(r,z)∈X}\{(r, 0, z) : (r, z) \in X\} about the zz axis. Let s=px2+py2s = p_x^2 + p_y^2.

  1. p∈Vp \in V exactly when (s,pz)∈X(\sqrt{s}, p_z) \in X.
  2. If s>0s > 0, then p∈int⁡Vp \in \operatorname{int} V exactly when (s,pz)∈int⁡X(\sqrt{s}, p_z) \in \operatorname{int} X.
  3. If s=0s = 0, then p∈int⁡Vp \in \operatorname{int} V exactly when there is ε>0\varepsilon > 0 such that the half-disk {(r,z):r≥0,r2+(z−pz)2<ε2}\{(r, z) : r \ge 0, r^2 + (z - p_z)^2 < \varepsilon^2\} is in XX.

Proof. The turn by θ\theta maps (r,0,z)(r, 0, z) to (rcos⁡θ,rsin⁡θ,z)(r \cos \theta, r \sin \theta, z), whose distance to the axis is r≥0r \ge 0. So the union is VV by Lemma 1, and part 1 is the definition of VV. For part 2, the map P(r,θ,z)=(rcos⁡θ,rsin⁡θ,z)P(r, \theta, z) = (r \cos\theta, r\sin\theta, z) is a local diffeomorphism on r>0r > 0, and near pp the function ρ(x,y,z)=(x2+y2,z)\rho(x, y, z) = (\sqrt{x^2 + y^2}, z) is continuous, open as a map onto a neighbourhood of (s,pz)(\sqrt s, p_z) in the open half-plane r>0r > 0, and V=ρ−1(X)V = \rho^{-1}(X). If (s,pz)(\sqrt s, p_z) has a neighbourhood U⊆XU \subseteq X, then ρ−1(U)\rho^{-1}(U) is an open neighbourhood of pp inside VV. If pp has a neighbourhood W⊆VW \subseteq V, then ρ(W)\rho(W) is a neighbourhood of (s,pz)(\sqrt s, p_z) inside XX, since ρ\rho is open there. For part 3, a ball BB of radius ε\varepsilon around a point pp on the axis maps under ρ\rho onto exactly the half-disk of radius ε\varepsilon around (0,pz)(0, p_z), so B⊆VB \subseteq V exactly when that half-disk is in XX. □\square

Lemma 4 (exact comparisons with s\sqrt{s}). For rational s≥0s \ge 0 and rational qq, sign⁡(s−q)\operatorname{sign}(\sqrt{s} - q) is +1+1 if q<0q < 0, and sign⁡(s−q2)\operatorname{sign}(s - q^2) if q≥0q \ge 0.

Proof. If q<0q < 0 then s≥0>q\sqrt{s} \ge 0 > q. If q≥0q \ge 0, both s\sqrt s and qq are in [0,∞)[0, \infty), where x↦x2x \mapsto x^2 is strictly increasing, so s\sqrt s and qq compare as ss and q2q^2 do. □\square

The crossing rule and the on-edge test use the first coordinate uu of the query point only in comparisons u<qu < q, u=qu = q, u≤qu \le q with rational qq: the crossing rcr_c of an edge with the line z=pzz = p_z is rational, since the edge has rational ends and pzp_z is rational, and the ends of a horizontal edge are rational. By Lemma 4 every such comparison is exact for u=su = \sqrt s, so line L8 computes CLASSIFY-PROFILE(XX, (s,pz)(\sqrt s, p_z)) exactly.

Lemma 5 (the axis test). Let XX be bounded by a simple polygon in r≥0r \ge 0 and let (0,z0)∈∂X(0, z_0) \in \partial X. The half-disk condition of Lemma 3, part 3, holds exactly when the edges of XX on the line r=0r = 0 cover a segment {0}×[z0−δ,z0+δ]\{0\} \times [z_0 - \delta, z_0 + \delta] for some δ>0\delta > 0.

Proof. Suppose the half-disk of radius ε\varepsilon is in XX. Then the points (0,z)(0, z) with ∣z−z0∣<ε|z - z_0| < \varepsilon are in XX, and they are on ∂X\partial X, since points with r<0r < 0 are arbitrarily close and not in XX. The boundary of XX is the polygon, so these points lie on edges; a segment of the line r=0r = 0 covered by finitely many edges is covered by edges that lie on the line, except for finitely many points where an edge crosses it, and closedness of the edges then covers those points too. So the edges on the axis cover the segment, with δ=ε/2\delta = \varepsilon / 2.

Conversely, suppose edges on r=0r = 0 cover {0}×[z0−δ,z0+δ]\{0\} \times [z_0 - \delta, z_0 + \delta]. Take ε≤δ\varepsilon \le \delta smaller than the distance from (0,z0)(0, z_0) to every edge of the polygon that is not on the axis and does not contain (0,z0)(0, z_0). Any edge that contains (0,z0)(0, z_0) and is not on the axis would leave the axis at (0,z0)(0, z_0); but then three edges, two on the axis above and below and this one, would meet at (0,z0)(0, z_0), or one of the axis edges would cross it in its relative interior, which a simple polygon does not allow, since the axis edges already cover both sides of (0,z0)(0, z_0) and a vertex of a simple polygon has exactly two edges. So inside the disk of radius ε\varepsilon, the polygon boundary is only the axis segment. The open half-disk with r>0r > 0 is then connected and misses ∂X\partial X, so it is wholly in int⁡X\operatorname{int} X or wholly outside XX. It is not outside: the axis points are in ∂X\partial X, so each has points of int⁡X\operatorname{int} X arbitrarily close, and those cannot have r<0r < 0. So the half-disk, with its axis diameter, is in XX. □\square

Theorem. CLASSIFY-EXTRUSION and CLASSIFY-REVOLUTION return IN for points of the interior of the solid, ON for points of its boundary and OUT for points outside it, when the representation is valid. Both stop after O(n)O(n) exact operations.

Proof. Extrusion: line L1 computes t∗t^* of Lemma 2, line L2 returns OUT when t∗∉[0,1]t^* \notin [0, 1], and lines L3 and L4 classify qq. If cc = OUT then p∉Ep \notin E by Lemma 2. Otherwise p∈Ep \in E, and by Lemma 2 it is interior exactly when 0<t∗<10 < t^* < 1 and cc = IN. Line L5 returns ON when t∗∈{0,1}t^* \in \{0, 1\}, and line L6 returns cc, which is IN or ON as required. Since EE is closed, a point of EE that is not interior is on its boundary.

Revolution: by the remark after Lemma 4, line L8 gives the class of (s,pz)(\sqrt s, p_z) against XX. If it is OUT, p∉Vp \notin V by Lemma 3, part 1. If s>0s > 0, Lemma 3, part 2, says pp is interior exactly when cc = IN, so line L9 returns the right answer. If s=0s = 0 and c≠c \neq OUT, then cc = ON, since (0,pz)(0, p_z) has points with r<0r < 0 arbitrarily close. Then by Lemma 3, part 3, and Lemma 5, pp is interior exactly when the axis edges cover a neighbourhood of (0,pz)(0, p_z) on the axis, which is the test of line L10: an edge on the axis that contains (0,pz)(0, p_z) and has an end above pzp_z covers a segment above it, and likewise below. Otherwise p∈V∖int⁡V=∂Vp \in V \setminus \operatorname{int} V = \partial V, line L11.

Each line does a constant number of operations, except L4, L8 and L10, which loop once over the nn edges. So both procedures stop after O(n)O(n) exact operations on numbers formed from the input coordinates. □\square

Volumes. For an extrusion, every slice z=cz = c with cc between 00 and dzd_z is a translate of XX, so by Cavalieri's principle the volume is area⁡(X)⋅∣dz∣\operatorname{area}(X) \cdot |d_z|, line V1. For a revolution, the volume in cylindrical coordinates is ∬X∫02πr dθ dA=2π∬Xr dA\iint_X \int_0^{2\pi} r \, d\theta \, dA = 2\pi \iint_X r \, dA. By Green's theorem with the field (0,r2/2)(0, r^2 / 2), ∬Xr dA=∮∂X12r2 dz\iint_X r \, dA = \oint_{\partial X} \tfrac{1}{2} r^2 \, dz for a counterclockwise boundary, and on the straight edge from (ri,zi)(r_i, z_i) to (ri+1,zi+1)(r_{i+1}, z_{i+1}) the integral is 16(zi+1−zi)(ri2+riri+1+ri+12)\tfrac{1}{6}(z_{i+1} - z_i)(r_i^2 + r_i r_{i+1} + r_{i+1}^2). Summing over the edges and rearranging gives 16∑i(ri+ri+1)(rizi+1−ri+1zi)\tfrac{1}{6} \sum_i (r_i + r_{i+1})(r_i z_{i+1} - r_{i+1} z_i), the same telescoping identity as in the shoelace formula for the area. Taking the absolute value makes the result independent of the orientation, line V2. □\square

Complexity

  • CLASSIFY takes O(n)O(n) time: one pass over the edges of XX with a constant number of exact operations per edge. The fractions stay small, since each test uses only the input coordinates and the point.
  • VOLUME takes O(n)O(n) time and gives an exact rational number, times π\pi for a revolution.
  • CHECK takes O(n2)O(n^2) time with the plain test of all pairs of edges. A sweep-line test brings it to O(nlog⁡n)O(n \log n).
  • The representation takes Θ(n)\Theta(n) space. The B-rep of the same solid has Θ(n)\Theta(n) faces for an extrusion, and for a revolution it has one face of revolution per edge of XX that is not on the axis.

Variants

  • Partial revolution. Turn the profile by an angle less than a full turn. The classification adds a test of whether the direction of (px,py)(p_x, p_y) lies in the swept sector; with rational end directions this test is an exact cross product. The axis rule of line L10 then no longer applies, since the two end faces of the sector meet on the axis.
  • Drafted and tapered extrusions. The profile also shrinks or grows as it moves, so M(t)M(t) is an affine map with a scale. A slice of the solid is still one scaled copy of XX, and the classification has the same form.
  • Sweeps along a curve. The profile moves along a space curve with a moving frame, which gives a pipe or a spring. The boundary surface is a sweep surface, and self-intersection becomes the main difficulty.
  • Sweeps of solids. A solid moves along a path, as a cutting tool does. This is the swept volume problem, solved by envelopes or by sampling. When the solid only translates along a straight segment, the result is the Minkowski sum of the solid and the segment.
  • Surfaces of revolution. Revolving only the boundary curve gives a surface of revolution, the boundary of the solid of this page.

When to use it

Use a sweep when the shape comes from a drawing: prismatic parts, turned parts, profiles of pockets and bosses. In a feature-based or history-based modeler, each extrude or revolve step stores exactly this pair of profile and motion, and the system evaluates it to a B-rep and combines it with the rest of the part by Boolean operations. A sweep is also a good representation for direct queries on one primitive: point classification, volume and mass properties are exact and cheap. Do not use sweeps as the only representation of a whole part, since a union of sweeps is not a sweep.

Pitfalls

  • Points on the axis. A point on the axis of a revolution is on the boundary of the profile but can be inside the solid. Test the edges on the axis, as lines L10 and L11 do, or the cylinder in the example has a wrong axis line.
  • Profiles that cross the axis. If part of XX has r<0r < 0, the revolution does not describe what the drawing shows. Reject such a profile, or cut it at the axis and keep one side.
  • Flat extrusions. An extrusion with dz=0d_z = 0 has no volume. Check dz≠0d_z \neq 0 before line L1 divides by it.
  • Computing the radius. Computing s\sqrt{s} in floating point makes points on cylindrical faces fall in or out at random. Compare squares, as line L8 does.
  • Self-intersecting profiles. A profile with crossing edges gives a set that is not the closure of its interior along the crossings, and the even-odd rule gives holes the user did not draw. Run CHECK on input.
  • Booleans. The union, intersection or difference of two sweeps is in general not a sweep. Store the result as a CSG tree of sweeps or as a B-rep.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

sweep_representation.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/sweep-representation/. The authors are listed in prov/QNVPYX.jsonl.

"""Sweep representations of solids: extrusions and full revolutions of a polygon.

An Extrusion holds a simple polygon X in the plane z = 0 and a vector d with
d_z != 0. Its solid is the union of X + t d over t in [0, 1].

A Revolution holds a simple polygon X in the (r, z) half-plane r >= 0. Its
solid is the union over all angles a of the polygon turned by a about the
z axis.

Both classify a point with rational coordinates as IN, ON or OUT with exact
Fraction arithmetic. The revolution never computes the radius sqrt(x^2 + y^2):
it compares its square with the square of a rational number.
"""

from __future__ import annotations

from fractions import Fraction
from typing import Callable, Sequence

IN, ON, OUT = "IN", "ON", "OUT"

Num = Fraction | int
Point2 = tuple[Fraction, Fraction]
Point3 = tuple[Fraction, Fraction, Fraction]


def _sign(v: Num) -> int:
    return (v > 0) - (v < 0)


def _cross(o: Point2, a: Point2, b: Point2) -> Fraction:
    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])


def _on_segment(p: Point2, a: Point2, b: Point2) -> bool:
    return (_cross(a, b, p) == 0
            and min(a[0], b[0]) <= p[0] <= max(a[0], b[0])
            and min(a[1], b[1]) <= p[1] <= max(a[1], b[1]))


def _segments_meet(a: Point2, b: Point2, c: Point2, d: Point2) -> bool:
    d1, d2 = _sign(_cross(a, b, c)), _sign(_cross(a, b, d))
    d3, d4 = _sign(_cross(c, d, a)), _sign(_cross(c, d, b))
    if d1 * d2 < 0 and d3 * d4 < 0:
        return True
    return (_on_segment(c, a, b) or _on_segment(d, a, b)
            or _on_segment(a, c, d) or _on_segment(b, c, d))


def area2(poly: Sequence[Point2]) -> Fraction:
    """Twice the signed area of a polygon (positive if counterclockwise)."""
    n = len(poly)
    return sum((poly[i][0] * poly[(i + 1) % n][1] - poly[(i + 1) % n][0] * poly[i][1]
                for i in range(n)), Fraction(0))


def is_simple(poly: Sequence[Point2]) -> bool:
    """True if the closed polygon has at least 3 vertices, nonzero area and no
    two edges that meet except adjacent edges at their common vertex. O(n^2)."""
    n = len(poly)
    if n < 3 or area2(poly) == 0:
        return False
    for i in range(n):
        a, b = poly[i], poly[(i + 1) % n]
        if a == b:
            return False
        for j in range(i + 1, n):
            c, d = poly[j], poly[(j + 1) % n]
            if j == i + 1 or (i == 0 and j == n - 1):
                # adjacent edges: they may share only the common vertex
                shared = b if j == i + 1 else a
                other = d if j == i + 1 else c
                far = a if j == i + 1 else b
                if _cross(far, shared, other) == 0 and \
                        (_on_segment(other, far, shared) or _on_segment(far, shared, other)):
                    return False
                continue
            if _segments_meet(a, b, c, d):
                return False
    return True


def classify_profile(poly: Sequence[Point2], cmp_u: Callable[[Fraction], int],
                     z: Fraction) -> str:
    """Classify the point (u, z) against the closed polygon, where u is known
    only through cmp_u(q) = sign(u - q) for rational q. Crossing number with a
    ray towards +u and the half-open rule on vertices. O(n)."""
    inside = False
    n = len(poly)
    for i in range(n):
        (ar, az), (br, bz) = poly[i], poly[(i + 1) % n]
        if az == bz:
            if z == az and cmp_u(min(ar, br)) >= 0 and cmp_u(max(ar, br)) <= 0:
                return ON
            continue
        if min(az, bz) <= z <= max(az, bz):
            rc = ar + (z - az) * (br - ar) / (bz - az)
            c = cmp_u(rc)
            if c == 0:
                return ON
            if (az > z) != (bz > z) and c < 0:
                inside = not inside
    return IN if inside else OUT


def cmp_rational(u: Fraction) -> Callable[[Fraction], int]:
    return lambda q: _sign(u - q)


def cmp_sqrt(s: Fraction) -> Callable[[Fraction], int]:
    """sign(sqrt(s) - q) for s >= 0, exactly, by comparing s with q^2."""
    def cmp(q: Fraction) -> int:
        if q < 0:
            return 1
        return _sign(s - q * q)
    return cmp


def _f(v: Num) -> Fraction:
    return Fraction(v)


class Extrusion:
    """The translational sweep of a polygon X in z = 0 along the vector d.

    Precondition: X is simple and d_z != 0. classify and volume take O(n) time
    for n vertices; the representation takes Theta(n) space.
    """

    def __init__(self, profile: Sequence[tuple[Num, Num]], d: tuple[Num, Num, Num]):
        self.profile: list[Point2] = [(_f(x), _f(y)) for x, y in profile]
        self.d: Point3 = (_f(d[0]), _f(d[1]), _f(d[2]))

    def check_invariant(self) -> bool:
        return self.d[2] != 0 and is_simple(self.profile)

    def classify(self, p: tuple[Num, Num, Num]) -> str:
        px, py, pz = _f(p[0]), _f(p[1]), _f(p[2])
        dx, dy, dz = self.d
        t = pz / dz  # @line L1
        if t < 0 or t > 1:  # @line L2
            return OUT
        q = (px - t * dx, py - t * dy)  # @line L3
        c = classify_profile(self.profile, cmp_rational(q[0]), q[1])  # @line L4
        if c != OUT and (t == 0 or t == 1):  # @line L5
            return ON
        return c  # @line L6

    def volume(self) -> Fraction:
        """The exact volume: area(X) times |d_z| (Cavalieri)."""
        return abs(area2(self.profile)) / 2 * abs(self.d[2])


class Revolution:
    """The full rotational sweep of a polygon X in the half-plane r >= 0 of
    the (r, z) plane about the z axis.

    Precondition: X is simple and every vertex has r >= 0. classify and
    volume take O(n) time; the representation takes Theta(n) space.
    """

    def __init__(self, profile: Sequence[tuple[Num, Num]]):
        self.profile: list[Point2] = [(_f(r), _f(z)) for r, z in profile]

    def check_invariant(self) -> bool:
        return all(r >= 0 for r, _ in self.profile) and is_simple(self.profile)

    def _axis_covers(self, z: Fraction) -> bool:
        """True if edges of X on the axis r = 0 contain (0, z) and reach both
        above and below it."""
        up = down = False
        n = len(self.profile)
        for i in range(n):
            (ar, az), (br, bz) = self.profile[i], self.profile[(i + 1) % n]
            if ar == 0 and br == 0 and min(az, bz) <= z <= max(az, bz):
                up = up or max(az, bz) > z
                down = down or min(az, bz) < z
        return up and down

    def classify(self, p: tuple[Num, Num, Num]) -> str:
        px, py, pz = _f(p[0]), _f(p[1]), _f(p[2])
        s = px * px + py * py  # @line L7
        c = classify_profile(self.profile, cmp_sqrt(s), pz)  # @line L8
        if s > 0 or c == OUT:  # @line L9
            return c
        if self._axis_covers(pz):  # @line L10
            return IN
        return ON  # @line L11

    def volume_over_pi(self) -> Fraction:
        """The exact volume divided by pi. By Pappus, V = 2 pi times the first
        moment of X about the axis, and the moment of a polygon is
        (1/6) sum (r_i + r_{i+1}) (r_i z_{i+1} - r_{i+1} z_i)."""
        poly, n = self.profile, len(self.profile)
        m = sum(((poly[i][0] + poly[(i + 1) % n][0])
                 * (poly[i][0] * poly[(i + 1) % n][1] - poly[(i + 1) % n][0] * poly[i][1])
                 for i in range(n)), Fraction(0)) / 6
        return 2 * abs(m)
test_sweep_representation.py 316 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/sweep-representation/. The authors are listed in prov/QNVPYX.jsonl.

import math
import random
import unittest
from fractions import Fraction as F

from sweep_representation import IN, ON, OUT, Extrusion, Revolution, area2, is_simple

EPS = F(1, 1000)


# ---------------------------------------------------------------------------
# Independent oracles. The profile test is a winding number, not the crossing
# number of the implementation, and the sweep is the plain union of M(t) X
# over a finite sample of the parameter t.
# ---------------------------------------------------------------------------

def cross(o, a, b):
    return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])


def in_closed_polygon(poly, q):
    """Winding number with an exact on-edge test. True for points of the
    closed polygon."""
    n = len(poly)
    w = 0
    for i in range(n):
        a, b = poly[i], poly[(i + 1) % n]
        if cross(a, b, q) == 0 and min(a[0], b[0]) <= q[0] <= max(a[0], b[0]) \
                and min(a[1], b[1]) <= q[1] <= max(a[1], b[1]):
            return True
        if a[1] <= q[1]:
            if b[1] > q[1] and cross(a, b, q) > 0:
                w += 1
        elif b[1] <= q[1] and cross(a, b, q) < 0:
            w -= 1
    return w != 0


def extrusion_member(profile, d, p, ts):
    """p is in the union of X + t d over the sampled t."""
    for t in ts:
        if p[2] == t * d[2] and in_closed_polygon(profile, (p[0] - t * d[0], p[1] - t * d[1])):
            return True
    return False


def rot(c, s, p):
    return (c * p[0] - s * p[1], s * p[0] + c * p[1], p[2])


def revolution_member(profile, p, rots):
    """p is in the union of R(a) X over the sampled rotations R(a), where X
    sits in the half-plane y = 0, x >= 0."""
    for c, s in rots:
        x, y, z = rot(c, -s, p)  # R(a)^-1 p
        if y == 0 and x >= 0 and in_closed_polygon(profile, (x, z)):
            return True
    return False


def pythagorean_rotations(limit):
    """Rational rotations (cos, sin) = ((a^2 - b^2)/h, 2ab/h), h = a^2 + b^2,
    together with their quarter turns and their negatives."""
    out = {(F(1), F(0))}
    for a in range(1, limit + 1):
        for b in range(0, limit + 1):
            h = a * a + b * b
            c, s = F(a * a - b * b, h), F(2 * a * b, h)
            for cc, ss in ((c, s), (-s, c), (-c, -s), (s, -c)):
                out.add((cc, ss))
    return sorted(out)


ROTS = pythagorean_rotations(3)


def primitive_directions(m):
    return [(a, b) for a in range(-m, m + 1) for b in range(-m, m + 1)
            if (a, b) != (0, 0) and math.gcd(a, b) == 1]


DIRS = primitive_directions(8)


def random_star_polygon(rng, lo=0, hi=4):
    """A simple lattice polygon: lattice points sorted by angle around a
    centre that is on no line through two lattice points of the box."""
    while True:
        k = rng.randrange(3, 8)
        pts = list({(rng.randrange(lo, hi + 1), rng.randrange(lo, hi + 1)) for _ in range(k)})
        if len(pts) < 3:
            continue
        cx, cy = sum(p[0] for p in pts) / len(pts) + 0.0137, sum(p[1] for p in pts) / len(pts) + 0.0071
        pts.sort(key=lambda p: math.atan2(p[1] - cy, p[0] - cx))
        poly = [(F(x), F(y)) for x, y in pts]
        if is_simple(poly):
            if area2(poly) < 0:
                poly.reverse()
            return poly


def random_rational(rng, lo, hi, den=4):
    return F(rng.randrange(lo * den, hi * den + 1), den)


class TestHandCases(unittest.TestCase):
    def test_oblique_prism(self):
        e = Extrusion([(0, 0), (2, 0), (2, 2), (0, 2)], (1, 0, 3))
        self.assertTrue(e.check_invariant())
        self.assertEqual(e.classify((2, 1, F(3, 2))), IN)
        self.assertEqual(e.classify((3, 1, 3)), ON)
        self.assertEqual(e.classify((F(1, 5), 1, F(3, 2))), OUT)
        self.assertEqual(e.classify((1, 1, 0)), ON)
        self.assertEqual(e.classify((1, 1, -1)), OUT)
        self.assertEqual(e.volume(), 12)

    def test_ring_and_cylinder(self):
        ring = Revolution([(1, 0), (2, 0), (2, 1), (1, 1)])
        self.assertTrue(ring.check_invariant())
        self.assertEqual(ring.classify((1, 1, F(1, 2))), IN)       # radius sqrt 2
        self.assertEqual(ring.classify((0, 0, F(1, 2))), OUT)
        self.assertEqual(ring.classify((F(3, 5), F(4, 5), F(1, 2))), ON)  # radius 1
        self.assertEqual(ring.volume_over_pi(), 3)
        cyl = Revolution([(0, 0), (2, 0), (2, 1), (0, 1)])
        self.assertEqual(cyl.classify((0, 0, F(1, 2))), IN)        # axis point
        self.assertEqual(cyl.classify((0, 0, 1)), ON)
        self.assertEqual(cyl.classify((1, 1, 1)), ON)               # top face, radius sqrt 2
        self.assertEqual(cyl.classify((1, 1, F(1, 2))), IN)
        self.assertEqual(cyl.classify((2, 1, F(1, 2))), OUT)        # radius sqrt 5
        self.assertEqual(cyl.volume_over_pi(), 4)

    def test_cone_apex(self):
        cone = Revolution([(0, 0), (1, 0), (0, 1)])
        self.assertEqual(cone.classify((0, 0, 1)), ON)
        self.assertEqual(cone.classify((0, 0, F(1, 2))), IN)
        self.assertEqual(cone.volume_over_pi(), F(1, 3))

    def test_invalid(self):
        self.assertFalse(Extrusion([(0, 0), (1, 0), (0, 1)], (1, 1, 0)).check_invariant())
        self.assertFalse(Revolution([(-1, 0), (1, 0), (0, 1)]).check_invariant())
        self.assertFalse(Revolution([(0, 0), (2, 2), (2, 0), (0, 2)]).check_invariant())


class TestExtrusionAgainstSampling(unittest.TestCase):
    def test_membership(self):
        rng = random.Random(11)
        n = 20
        for _ in range(500):
            poly = random_star_polygon(rng)
            d = (rng.randrange(-2, 3), rng.randrange(-2, 3), rng.choice([-3, -2, -1, 1, 2, 3]))
            d = tuple(F(v) for v in d)
            e = Extrusion(poly, d)
            ts = [F(k, n) for k in range(-2, n + 3)]
            t = rng.choice(ts)
            p = (random_rational(rng, -3, 7), random_rational(rng, -3, 7), t * d[2])
            want = extrusion_member(poly, d, p, [x for x in ts if 0 <= x <= 1])
            self.assertEqual(e.classify(p) != OUT, want, (poly, d, p))

    def test_in_and_on_by_probes(self):
        rng = random.Random(12)
        n = 4
        for _ in range(300):
            poly = random_star_polygon(rng)
            d = (F(rng.randrange(-2, 3)), F(rng.randrange(-2, 3)), F(rng.choice([1, 2, 3])))
            e = Extrusion(poly, d)
            t = F(rng.randrange(0, n + 1), n)
            q = (random_rational(rng, 0, 4), random_rational(rng, 0, 4))
            p = (q[0] + t * d[0], q[1] + t * d[1], t * d[2])
            got = e.classify(p)
            ts = [t, t - EPS, t + EPS]
            ts = [x for x in ts if 0 <= x <= 1]
            if not extrusion_member(poly, d, p, ts):
                self.assertEqual(got, OUT)
                continue
            probes = [(p[0] + EPS * a, p[1] + EPS * b, p[2]) for a, b in DIRS]
            probes += [tuple(p[i] + sg * EPS * d[i] for i in range(3)) for sg in (1, -1)]
            inside = all(extrusion_member(poly, d, x, ts) for x in probes)
            self.assertEqual(got, IN if inside else ON, (poly, d, p))

    def test_sweep_of_profile_points(self):
        """Every point x + t d with x in X and t in [0, 1] is in the solid."""
        rng = random.Random(13)
        for _ in range(500):
            poly = random_star_polygon(rng)
            d = (F(rng.randrange(-2, 3)), F(rng.randrange(-2, 3)), F(rng.choice([-2, -1, 1, 2])))
            e = Extrusion(poly, d)
            x = rng.choice(poly) if rng.random() < 0.3 else \
                (random_rational(rng, 0, 4, 7), random_rational(rng, 0, 4, 7))
            if not in_closed_polygon(poly, x):
                continue
            t = F(rng.randrange(0, 1001), 1000)
            p = (x[0] + t * d[0], x[1] + t * d[1], t * d[2])
            self.assertNotEqual(e.classify(p), OUT)

    def test_volume_against_grid(self):
        rng = random.Random(14)
        for _ in range(3):
            poly = random_star_polygon(rng)
            d = (F(1), F(0), F(2))
            e = Extrusion(poly, d)
            m = 8
            count = 0
            for i in range(m):
                for j in range(5 * m):
                    for k in range(5 * m):
                        p = (F(2 * j + 1, 2 * m) - 0, F(2 * k + 1, 2 * m), F(2 * i + 1, m))
                        if e.classify(p) != OUT:
                            count += 1
            est = F(count, m * m * m) * 2
            self.assertLess(abs(float(est - e.volume())), 0.6)


class TestRevolutionAgainstSampling(unittest.TestCase):
    def profile(self, rng):
        poly = random_star_polygon(rng)
        if rng.random() < 0.5:
            shift = min(r for r, _ in poly)
            poly = [(r - shift, z) for r, z in poly]
        return poly

    def test_membership(self):
        rng = random.Random(21)
        for _ in range(500):
            poly = self.profile(rng)
            v = Revolution(poly)
            self.assertTrue(v.check_invariant())
            c, s = rng.choice(ROTS)
            base = (random_rational(rng, 0, 5), F(0), random_rational(rng, -1, 5))
            if rng.random() < 0.1:
                base = (F(0), F(0), base[2])
            p = rot(c, s, base)
            want = revolution_member(poly, p, ROTS)
            self.assertEqual(v.classify(p) != OUT, want, (poly, p))

    def test_in_and_on_by_probes(self):
        rng = random.Random(22)
        tiny = (F(1000 * 1000 - 1, 1000 * 1000 + 1), F(2 * 1000, 1000 * 1000 + 1))
        for _ in range(300):
            poly = self.profile(rng)
            v = Revolution(poly)
            c, s = rng.choice(ROTS)
            r = random_rational(rng, 0, 4) if rng.random() < 0.8 else F(0)
            z = random_rational(rng, 0, 4)
            p = rot(c, s, (r, F(0), z))
            got = v.classify(p)
            rots = list(ROTS)
            # the turns that bring the probes back into the profile half-plane
            rots += [(c * tiny[0] - s * tiny[1], s * tiny[0] + c * tiny[1]),
                     (c * tiny[0] + s * tiny[1], s * tiny[0] - c * tiny[1])]
            if not revolution_member(poly, p, rots):
                self.assertEqual(got, OUT)
                continue
            # probes in the half-plane of p, and two small turns of p
            probes = [rot(c, s, (r + EPS * a, F(0), z + EPS * b)) for a, b in DIRS]
            probes += [rot(tiny[0], tiny[1], p), rot(tiny[0], -tiny[1], p)]
            inside = all(revolution_member(poly, x, rots) for x in probes)
            self.assertEqual(got, IN if inside else ON, (poly, p))

    def test_irrational_radius_against_floats(self):
        rng = random.Random(23)
        checked = 0
        for _ in range(500):
            poly = self.profile(rng)
            v = Revolution(poly)
            p = (random_rational(rng, -4, 4, 3), random_rational(rng, -4, 4, 3),
                 random_rational(rng, 0, 4, 3))
            r = math.hypot(float(p[0]), float(p[1]))
            z = float(p[2])
            q = (r, z)
            fpoly = [(float(a), float(b)) for a, b in poly]
            # distance from (r, z) to the profile boundary, in floats
            dist = min(seg_dist(q, fpoly[i], fpoly[(i + 1) % len(fpoly)]) for i in range(len(fpoly)))
            if dist < 1e-6:
                continue
            want = IN if in_closed_polygon(fpoly, q) else OUT
            self.assertEqual(v.classify(p), want, (poly, p))
            checked += 1
        self.assertGreater(checked, 400)

    def test_volume_against_grid(self):
        rng = random.Random(24)
        for _ in range(5):
            poly = self.profile(rng)
            v = Revolution(poly)
            m = 40
            total = 0.0
            for i in range(4 * m):
                for j in range(4 * m):
                    rr, zz = (i + 0.5) / m, (j + 0.5) / m
                    if in_closed_polygon([(float(a), float(b)) for a, b in poly], (rr, zz)):
                        total += 2 * math.pi * rr / (m * m)
            self.assertLess(abs(total - float(v.volume_over_pi()) * math.pi), 0.5)

    def test_rotation_invariance(self):
        rng = random.Random(25)
        for _ in range(500):
            poly = self.profile(rng)
            v = Revolution(poly)
            p = (random_rational(rng, -4, 4, 2), random_rational(rng, -4, 4, 2),
                 random_rational(rng, 0, 4, 2))
            c, s = rng.choice(ROTS)
            self.assertEqual(v.classify(p), v.classify(rot(c, s, p)))


def seg_dist(q, a, b):
    ax, ay = b[0] - a[0], b[1] - a[1]
    t = ((q[0] - a[0]) * ax + (q[1] - a[1]) * ay) / (ax * ax + ay * ay)
    t = max(0.0, min(1.0, t))
    return math.hypot(q[0] - a[0] - t * ax, q[1] - a[1] - t * ay)


if __name__ == "__main__":
    unittest.main()

History

Solids made by moving a profile are as old as drafting, and the volume rule for revolutions is Pappus's centroid theorem from late antiquity, found again by Guldin in the seventeenth century. In solid modeling, Requicha's survey of 1980 listed translational and rotational sweeps as one of the representation schemes, next to CSG, cell decompositions and boundary representations, and noted that their domain is small. The modelers of the 1980s used extrusions and revolutions as the main way to turn drawings into solids, and kept them as primitives or converted them to B-reps. General sweeps of solids along paths, needed for machining and motion studies, were studied with envelope theory by Wang and Wang in 1986 and by Martin and Stephenson in 1990.

References

  1. Aristides A. G. Requicha, Representations for rigid solids, theory, methods, and systems, ACM Computing Surveys 12(4), 437 to 464, 1980, the section on sweep representations, translational and rotational sweeps, and their limited domain
  2. Martti Mäntylä, An Introduction to Solid Modeling, Computer Science Press, 1988, the chapter on representation schemes, the part on sweeping
  3. Ralph R. Martin and P. C. Stephenson, Sweeping of three-dimensional objects, Computer-Aided Design 22(4), 223 to 234, 1990, the sweep of a solid along a general path, built from the sweeps of its faces and their silhouette curves
  4. W. P. Wang and K. K. Wang, Geometric modeling for swept volume of moving solids, IEEE Computer Graphics and Applications 6(12), 1986, 8 to 17, the envelope of a moving solid and the self-intersection problems of general sweeps

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/QNVPYX/text.yaml