Skip to main content

Module deform

Module deform 

Source
Expand description

Maps of space applied to geometry: a rigid motion, a mirror or a scaling (Motion), and the deformations of a body about an axis — tapering (or pinching, one way across the axis), shearing, twisting and bending (AxialMap).

§One mechanism: composition on the control points

In a frame whose third axis is the deformation’s axis, an axial map takes the point (x, y, t) to x a(t) + y b(t) + c(t): affine in x and y, with coefficients that are functions of t alone. A taper scales x and y by a factor linear in t; a twist turns them by an angle linear in t; a shear moves them across by an offset linear in t; a bend carries the plane t = const round a circle, x measured towards its centre. Each coefficient is constant + slope s + cos·cos(rate s) + sin·sin(rate s) with s the distance along the axis from the zone’s start (AxialFunction).

On a Bézier piece of a NURBS, x, y and t are polynomials over the weight W. A coefficient that is a polynomial of degree d in t, written about the piece’s middle tc as Σ f_n (t - tc)^n, composes into Σ f_n U^n W^(d-n) / W^d with U = T - tc W: so the image of the piece is the rational Bézier piece of numerator Σ_i e_i (Â_i x̂ + B̂_i ŷ + Ĉ_i W) and weight W^(d+1), of d + 1 times the degree — computed from the control points by products of Bernstein polynomials ([crate::bernstein]), no evaluation, no fitting. The parametrization is kept, so every pcurve on a deformed face still traces it.

A taper’s coefficients are linear: the composition is exact. A twist’s and a bend’s are trigonometric: each is replaced by its cubic interpolant at Chebyshev points over the piece’s reach along the axis, whose error, (|cos| + |sin|) |rate|^4 / 4! · max |Π (τ - τ_j)|, is a proven bound; times what x and y reach over the piece, it bounds how far the composed piece can be from the true image, and every control point is widened by it (a polynomial piece stays polynomial, its weights exactly one). A piece whose bound is above the target is halved (along the direction it runs most along the axis) until it is below, and a curve or surface that would need more than MAX_PIECES pieces is refused by name. The pieces are joined back at knots of full multiplicity, the shared control points the union of the two enclosures.

§Zones

The law holds over the zone [start, end] along the axis. Before and after it the map continues as the affine map it is tangent to at the zone’s end (Motion::affine): rigidly for a twist or a bend, as a constant scaling across the axis for a taper. So a body is first divided where it crosses the zone’s ends (the operation imprints those planes), and each piece of it is moved by the piece of the map it lies in. The two agree on the plane they share.

Structs§

AxialFunction
constant + slope s + cos·cos(rate s) + sin·sin(rate s), with s = t - start: a coefficient of an AxialMap as a function of the coordinate t along its axis.
AxialMap
A taper, a twist or a bend about an axis (see the module’s doc): in the frame frame at origin — x, y and the axis, orthonormal and right-handed — the point (x, y, t) goes to x a(t) + y b(t) + c(t) over the zone start ≤ t ≤ end, columns being [a, b, c] by their components in the frame. Before and after the zone, the affine map the law is tangent to at its end.

Traits§

Deformation
A map of space as it moves geometry: points, curves and surfaces, each keeping its parametrization, so a pcurve on a moved face still traces it. at gives a point of the curve or of the face the surface bounds, asked for only by a map made of pieces where the geometry’s control points straddle two of them: the piece that holds at moves it.