Skip to content

scatter3d

Mojo module 🡭

scatter3d

Mark.SCATTER3D and Mark.PLOT3D: points and polylines in three dimensions, projected through a Camera3D onto a Frame3D (#345).

The third of #345’s five steps, and the first that draws anything. Both marks are the same pipeline – normalise, project, sort, draw – and differ only in the glyph at the end, which is why they share a module and a data struct.

Depth sorting is the whole of the correctness. canvas is a painter’s-algorithm rasteriser with no z-buffer, so a nearer point hides a farther one only by being drawn second. For points that is a sort by projected depth and it is exact. For a polyline it is not: a line is drawn in data order, so a segment that passes behind another is drawn over it if it comes later in the series. The fix is splitting segments at their crossings, which needs geometry canvas does not have, so the behavior is stated here rather than left to be discovered.

Functions