mesh.cylinder

A closed faceted cylinder standing on a plane: side quads and two flat polygon caps.

GeometricSince 0.5.0

Usage

TypeScript
Mesh.cylinder(radius: number, height: number, segments?: number, plane?: Plane): Result<Mesh>

Parameters

  • radiusnumber

    Distance from the axis to every side point (the circumradius of the caps). Required. In model.

  • heightnumber

    Length along the plane’s normal. Required. In model.

  • segmentsnumber

    Side faces around the axis; an integer. Default 32. Range [3, 256] count.

  • planePlane

    The base: centred on its origin, the axis along its normal. Default Plane.worldXY. In model.

Returns

Ok with a closed, edge-manifold, outward mesh of 2 · segments points and segments + 2 faces.

Errors

Guarantees

  • validate() succeeds
  • volume() equals (segments / 2) · radius² · sin(2π / segments) · height, the prism’s exact volume, which tends to π · radius² · height
  • The same result on every machine.

Example

TypeScript
const r = Mesh.cylinder(1, 2, 64)
r.ok && r.value.faceCount // → 66

See also