curve2.chamfer

A chamfer line across the corner of two 2D curves, or at a chain’s corners, by two distances or a distance and an angle.

GeometricSince 0.18.0

Usage

TypeScript
Curve2.chamfer(target: readonly [IdCurve2, IdCurve2] | Chain2, cut: Curve2ChamferCut, options?: Curve2CornerOptions): Result<Curve2Edit>

Parameters

  • targetreadonly [IdCurve2, IdCurve2] | Chain2

    Two lines, arcs or cubics that meet, or a chain. Required. In model.

  • cutCurve2ChamferCut

    { distances: [d1, d2] } (arc length back along each curve from the corner) or { distance, angle } (radians, in (0, π), from the first curve). Required. In model.

  • options.pickPoint2

    Two curves: a point in the corner to cut; needed when they cross or meet more than once. Required. In model.

  • options.verticesreadonly (number | `#${number}`)[]

    A chain: the corners to cut.

    Required

  • options.scopestring

    The node id minted ids are keyed under.

    Required

  • options.dryRunboolean

    Return the outline only. Default false.

  • options.tolerancenumber

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

Returns

Ok with { outline, curves: [a, b, the line] } or { outline, chains: [the chain] }: the line runs from a’s cut to b’s, bit for bit.

Errors

Guarantees

  • both curves keep their ids; the line’s id does not depend on their order
  • The same result on every machine.

Example

TypeScript
const r = Curve2.chamfer([{ 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(0, 0), b: Point2.of(0, 10) }], { distances: [1, 2] })
r.ok ? r.value.outline : Result.error(r).code // → ok once loadGeometryKernel() has run; CAPABILITY_UNAVAILABLE before

See also