meshEdits.bend

A copy of a polygon mesh bent into a circular arc along an axis, its extent along the axis turning through a set angle.

GeometricSince 0.16.0

Usage

TypeScript
MeshEdits.bend(geometry: Geometry | VerbValue, params?: MeshBendParams): Result<VerbValue>

Parameters

  • geometryGeometry | VerbValue

    Polygon geometry; the input is not modified.

    Required

  • params.axis{ x?, y?, z? }

    The direction the model lies along, any length; a missing component is 0. Default { x: 1 }.

  • params.up{ x?, y?, z? }

    The direction the model bends toward; its part along the axis is removed. Default the first of +Y, +Z, +X whose cosine with the axis is below 0.9.

  • params.anglenumber

    The angle the model’s extent along the axis turns through; 0 returns the input, 2π closes it into a ring. Default 0. In radians.

Returns

Ok with a VerbValue (the caller frees it): the same points, corners and faces, each point moved onto the arc; data has points and faces.

Errors

Guarantees

  • with u a point’s coordinate along the axis and v along up, the spine (v = 0) keeps its length: the point at u lies at arc length u − (min u + max u) / 2 from the middle, which stays where it was; a point at v lies on the arc of radius R − v, R = extent / angle, toward up
  • the curvature is angle divided by the model’s extent along the axis; a model with no extent along it is returned as it is
  • every id, role, corner, face and other attribute is kept; lineage records every point and face as carried
  • the same input and parameters give the same bytes (geometryContentHash), natively and in WASM
  • The same result on every machine.

Example

TypeScript
const r = MeshEdits.bend(Mesh.box(Vector3.of(4, 1, 1)).value, { angle: Math.PI / 2 })
r.ok || r.diagnostics[0].code // → the bar bent a quarter turn toward +Y once loadGeometryKernel() has run

See also