Circle
function Canvas() { const geo = circle({ radius: 1, segments: 32 }) const mat = rotate3dX(iMouse.y.negate()).mul(rotate3dY(iMouse.x)) const gl = useGL({ isWebGL: true, isDepth: true, count: geo.count, vertex: vec4(mat.mul(geo.vertex), 1), fragment: vec4(varying(geo.normal), 1), }) return <canvas ref={gl.ref} /> }
Circle Props
| radius | The circle radius. Default is 1. |
|---|---|
| segments | Number of triangular segments (minimum = 3). Default is 32. |
| thetaStart | Start angle for first segment in radians. Default is 0. |
| thetaLength | The central angle sweep in radians. Default is Math.PI*2 (complete circle). |
Mathematical Construction
The circle geometry constructs a planar surface using triangular tessellation around a central vertex. Given a radius and angular resolution , vertices are distributed along the circumference according to:
where for each segment .
Geometric Properties
Each triangle connects the center point with adjacent circumference vertices. The triangulation pattern ensures uniform area distribution across the surface. Normal vectors remain constant at since the geometry lies entirely in the xy-plane.
Angular Parameterization
The thetaStart and thetaLength parameters enable precise control over angular coverage. A partial circle with creates a sector geometry, useful for pie charts or angular masks. The starting angle allows rotation of the opening direction.
Segment Count Effects
Lower segment counts produce polygon approximations of circles. Triangle count equals the segment count, with vertex count being segments plus one center vertex. Each triangle shares the central vertex, creating a fan topology.