Maths · function
boundsOfPositions
Measure a vertex array, into bounds the caller owns.
Explained in Coordinates and units.
function boundsOfPositions(positions: Float32Array, out: Bounds): Boundsimport { boundsOfPositions } from '@driftengine/core';Parameters
| Parameter | Type | Description |
|---|---|---|
positions | Float32Array | |
out | Bounds |
In depth
Two passes, and the second one is the point. The first finds the box; the second finds the furthest vertex from the box's midpoint. Half the diagonal would be one pass and would be the box's circumradius — right for a box, and loose for anything rounded, which is most geometry. A sphere that reaches the corners of a box the geometry never visits answers every test too generously, and the cost is a second walk of an array that is already in cache.
Measured about the box's centre and never about the origin. A mesh modelled a kilometre from the origin gets a kilometre-wide sphere the other way, and culls nothing for the rest of its life.
Allocates nothing: out is the caller's and is returned for convenience.