curve2.split

A 2D curve split at parameters, points or cutter curves, or a chain at vertices or inside segments, with persistent ids.

GeometricSince 0.18.0

Usage

TypeScript
Curve2.split(target: IdCurve2 | Chain2, at: Curve2SplitAt, options?: Curve2EditOptions): Result<Curve2Edit>

Parameters

  • targetIdCurve2 | Chain2

    The curve or chain to split. Required. In model.

  • atCurve2SplitAt

    { params } | { points } | { cutters } for a curve; { cuts: ({ vertex } | { segment, t })[] } for a chain, members by id or #k. Required. In model.

  • options.scopestring

    The node id minted ids are keyed under.

    Required

  • options.dryRunboolean

    Return the outline only. Default false.

  • options.tolerancenumber

    Distance under which a point is on the curve and cuts merge. Default 1e-9 × the bounds diagonal. In model.

Returns

Ok with { outline, curves } (a curve’s pieces in parameter order) or { outline, chains }; the piece holding the input’s start keeps its id, each other is minted keyed by the input and the cut at its start.

Errors

Guarantees

  • each piece ends exactly where the next starts; an arc’s pieces keep its centre bit for bit; the pieces’ lengths sum to the curve’s
  • The same result on every machine.

Example

TypeScript
const r = Curve2.split({ id: 1, minter: 0, kind: 'line', a: Point2.of(0, 0), b: Point2.of(10, 0) }, { params: [0.5] }, { scope: 'node-1' })
r.ok ? r.value.outline : Result.error(r).code // → ok once loadGeometryKernel() has run; CAPABILITY_UNAVAILABLE before

See also