fromVertices

fun fromVertices(positions: ReadonlyArray<Double>? = definedExternally, center: Cartesian3? = definedExternally, stride: Int? = definedExternally, result: BoundingSphere? = definedExternally): BoundingSphere(source)

Computes a tight-fitting bounding sphere enclosing a list of 3D points, where the points are stored in a flat array in X, Y, Z, order. The bounding sphere is computed by running two algorithms, a naive algorithm and Ritter's algorithm. The smaller of the two spheres is used to ensure a tight fit.

// Compute the bounding sphere from 3 positions, each specified relative to a center.
// In addition to the X, Y, and Z coordinates, the points array contains two additional
// elements per point which are ignored for the purpose of computing the bounding sphere.
const center = new Cartesian3(1.0, 2.0, 3.0);
const points = [1.0, 2.0, 3.0, 0.1, 0.2,
4.0, 5.0, 6.0, 0.1, 0.2,
7.0, 8.0, 9.0, 0.1, 0.2];
const sphere = BoundingSphere.fromVertices(points, center, 5);

Return

The modified result parameter or a new BoundingSphere instance if one was not provided.

Parameters

positions

An array of points that the bounding sphere will enclose. Each point is formed from three elements in the array in the order X, Y, Z.

center

The position to which the positions are relative, which need not be the origin of the coordinate system. This is useful when the positions are to be used for relative-to-center (RTC) rendering. Default value - Cartesian3.ZERO

stride

The number of array elements per vertex. It must be at least 3, but it may be higher. Regardless of the value of this parameter, the X coordinate of the first position is at array index 0, the Y coordinate is at array index 1, and the Z coordinate is at array index

  1. When stride is 3, the X coordinate of the next position then begins at array index 3. If the stride is 5, however, two array elements are skipped and the next position begins at array index 5. Default value - 3

result

The object onto which to store the result.

See also