meshEdits.twist

A copy of a polygon mesh with every point turned about an axis by an angle proportional to its coordinate along it.

GeometricSince 0.16.0

Usage

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

Parameters

  • geometryGeometry | VerbValue

    Polygon geometry; the input is not modified.

    Required

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

    The axis, through the origin, any length; a missing component is 0. Default { y: 1 }.

  • params.anglePerUnitnumber

    How far a point turns per model unit of its coordinate along the axis, by the right hand about it; 0 returns the input. Default 0. In radians.

Returns

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

Errors

Guarantees

  • a point p turns by θ = anglePerUnit · (a · p) about the unit axis a, so it keeps its distance to the axis and its coordinate along it; a point with θ = 0 keeps its position exactly
  • twisting the result by −anglePerUnit about the same axis gives the input back, to rounding
  • 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.twist(Mesh.box().value, { axis: { y: 1 }, anglePerUnit: 0.5 })
r.ok || r.diagnostics[0].code // → the box turned half a radian per unit up Y once loadGeometryKernel() has run

See also