Method Cylinder
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
Cylinder(float, float, float, int)
Builds a tessellated cylinder about the y axis.
public static ConvexHull Cylinder(float height, float radius, float baseHeight = 0, int sides = 16)Parameters
heightfloat-
The total height.
radiusfloat-
The radius.
baseHeightfloat-
Where the flat base sits along the y axis. The cylinder then extends up to
baseHeight + height. sidesint-
The number of sides around the circumference, from 3 to 32.
Returns
- ConvexHull
-
The hull.
Examples
// A barrel standing on the body origin.
using var barrel = ConvexHull.Cylinder(height: 1.2f, radius: 0.4f);
// The same barrel centred on the origin instead.
using var centred = ConvexHull.Cylinder(1.2f, 0.4f, baseHeight: -0.6f);
Remarks
The cylinder stands on the origin rather than being centred on it.
A cylinder built with the default baseHeight occupies
y from 0 to height, so a body carrying one rests with
its origin on the ground. Pass -height / 2 to centre it.