How to triangulate a polyline with thickness
https://jvernay.fr/en/blog/polyline-triangulation/ [jvernay.fr]
2025-01-05 22:33
To render any geometric figure to a GPU (with OpenGL / Direct3D / Vulkan / ...), they must first be triangulated, i.e. decomposed as a series of triangles. Some figures are trivial to transform into triangles: for instance, a segment with thickness is represented by a rectangle, which can be rendered with two triangles. But a segment strip with thickness (aka. polyline) is not trivial.
Ultimately, this exploration has been a rabbit hole, also partly due to some digressions along the path โ letโs prototype with a bare implementation of GeoGebra in vanilla JavaScript โ letโs do a WebGL + WASM demo to verify the algorithm works correctly ... ๐ At least, it gives some fancy interactive visuals for this blog post. ๐
source: HN