deform
Applies a deformation to the line segment by introducing intermediate control points influenced by an attractor vector and a specified strength.
Return
A new Segment2D object with added control points representing the deformed line segment.
Parameters
The vector that acts as the attractor point influencing the deformation.
The strength of the deformation, determining how significantly the line segment bends toward the attractor.
Approximates the shape curve would take if every point on it were pulled toward attractor by a distance-weighted force, with both endpoints pinned. Adaptively splits into more pieces wherever a single cubic Bezier can't fit the displacement field within errorTolerance.
Displacement field (defined over the GLOBAL parameter t of the input curve, so taper only varies along the true curve, not per split piece):
D(t) = B(t) + strength * taper(t) * fall(t) * (attractor - B(t)) taper(t) = (1 - endpointPinning) + endpointPinning * 4t(1-t) fall(t) = 1 / (1 + (dist(t) / refDistance)^falloff)
taper(t) blends between two extremes: endpointPinning = 0 -> taper(t) = 1 everywhere, so the endpoints are pulled exactly as strongly (relative to their own distance) as any interior point - the whole curve is "attracted". endpointPinning = 1 -> taper(t) = 4t(1-t), which is 0 at t=0,1, reproducing the original pinned-rod behavior (fixed endpoints). Values in between give partial resistance at the ends.
Each candidate piece is fit with its endpoints FIXED to the true displaced position at its t-range boundaries (not the original curve's position) so neighboring pieces always join up exactly, regardless of endpointPinning.
Parameters
original cubic Bezier
the attracting point
overall pull strength; ~0 = no bend, ~1 = strong bend
distance falloff exponent (0 = uniform, 2 = gravity-like)
normalizes falloff so it doesn't blow up near the attractor
0 = endpoints move like any other point (fully attracted), 1 = endpoints stay fixed in place (fully pinned), values in between blend smoothly. Default is fully attracted.
max allowed RMS fit error (same units as the curve's coordinates) before a piece is split in two
recursion limit; caps output at 2^maxDepth pieces. Keep this modest (5-8) — it's a hard ceiling, not a target.
interior samples used both for fitting and for measuring the resulting error
Deforms the current ShapeContour by applying an attraction force toward a given attractor point. The deformation is influenced by various parameters including strength, falloff, and reference distance, and adaptively refines the contour where necessary to meet an error tolerance.
Return
A new ShapeContour representing the deformed version of the original.
Parameters
The vector representing the point toward which the contour is attracted.
The magnitude of the attraction force, where higher values result in greater deformation.
The exponent controlling how the attraction force decreases with distance from the attractor.
A reference distance that normalizes the falloff effect, preventing excessive influence near the attractor.
The maximum allowed root mean square (RMS) error for approximating the deformed contour. Default is 0.5.
The maximum recursion depth for refining the contour, limiting the number of pieces in the output. Default is 6.
The number of interior sample points used for both fitting and measuring deformation errors. Default is 24.