Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

curve.smooth (procNode)

Round every curve of a geometry into a Catmull-Rom spline through its own points, resampled to a denser curve. The new points carry the attributes of the points they lie between, blended.

Per curve (n - 1 + closed) * segments + (1 - closed) points (n when segments is 1 or the curve has fewer than 3 points, which come through as they are). curve.lay_points gives each new point its curve and index; the span is floor(index / segments) and the position inside it (index % segments) / segments. The four control points are gathered through the curve's vertex-to-point link (wrapping on a closed curve, clamped on an open one) and the spline is evaluated by the Barry-Goldman pyramid of lerps on the knots |q - p| ^ alpha (every knot interval is 1 at alpha 0). Each new point carries the blend of the curve points its span lies between (core.interpolate).

Built from: curve.lay_points, field.gather, core.points, core.interpolate, curve.strands, attribute.number, vector.*, math.*.

Inputs

  • curve (Curves). The curves to round. Each passes through every one of its points after, and keeps its open/closed choice.
  • segments (Float). Default 8. At least 1. Spans between each pair of points. 1 reproduces the input.
  • alpha (Float). Default 0.5. 0 to 1. The Catmull-Rom parameterisation: 0.5 (centripetal) follows the points without loops or overshoot whatever their spacing, 0 (uniform) swings wider through uneven spacing, 1 (chordal) wider still.

Outputs

  • curve: the rounded curves, each point numbered as id. The counts stay on the device, so the curve is allocated for more points than it holds.

Example

local corners = g.core.points({ count = 4, columns = { P = vector.create(g.element.id, (g.element.id % 2) * 1.0, 0) } })
local path = g.curve.from_points({ points = corners })
local smooth = g.curve.smooth({ curve = path, segments = 4, alpha = 0.5 })

The open zigzag of four points becomes one curve of 13 points through them.