curve2.intersect

Every crossing, touch and overlap between pairs of 2D curves, or of one curve with a set, named by id.

GeometricSince 0.18.0

Usage

TypeScript
Curve2.intersect(curves: readonly IdCurve2[], options?: Curve2Options & { curve?: IdCurve2 }): Result<Curve2Hit[]>

Parameters

  • curvesreadonly IdCurve2[]

    Lines, arcs, circles and cubics with ids. Required. In model.

  • options.curveIdCurve2

    Intersect this one curve with each of curves instead of every pair. Required. In model.

  • options.tolerancenumber

    Distance under which curves touch. Default 1e-9 × the bounds diagonal. In model.

Returns

Ok with the hits { a, b, ta, tb, point, kind, overlap? }, sorted by (a.id, ta, b.id, tb); a is the lower id of a pair (or options.curve).

Errors

Guarantees

  • every hit point lies within the tolerance of both curves, at parameters ta and tb
  • the hits of a pair are the same bits whichever curve comes first
  • The same result on every machine.

Example

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

See also