BoundingSphere

BoundingSphere

new

A bounding sphere with a center and a radius.

Parameters:
Name Type Argument Default Description
center Cartesian3 <optional>
Cartesian3.ZERO The center of the bounding sphere.
radius Number <optional>
0.0 The radius of the bounding sphere.
See:
Source:

Members

:Cartesian3

The center point of the sphere.

:Number

The radius of the sphere.

Methods

Duplicates this BoundingSphere instance.

Parameters:
Name Type Argument Description
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

Compares this BoundingSphere against the provided BoundingSphere componentwise and returns true if they are equal, false otherwise.

Parameters:
Name Type Argument Description
right BoundingSphere <optional>
The right hand side BoundingSphere.
Returns:
Boolean true if they are equal, false otherwise.

Computes a bounding sphere that is sphere expanded to contain point.

Parameters:
Name Type Argument Description
point Cartesian3 A point to enclose in a bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
DeveloperError : point is required.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if one was not provided.

The distances calculated by the vector from the center of the bounding sphere to position projected onto direction plus/minus the radius of the bounding sphere.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding sphere.

Parameters:
Name Type Argument Description
position Cartesian3 The position to calculate the distance from.
direction Cartesian3 The direction from position.
result Cartesian2 <optional>
A Cartesian2 to store the nearest and farthest distances.
Throws:
Returns:
Interval The nearest and farthest distances on the bounding sphere from position in direction.

Determines which side of a plane the sphere is located.

Parameters:
Name Type Description
plane Cartesian4 The coefficients of the plane in the for ax + by + cz + d = 0 where the coefficients a, b, c, and d are the components x, y, z, and w of the {Cartesian4}, respectively.
Throws:
DeveloperError : plane is required.
Returns:
Intersect {Intersect.INSIDE} if the entire sphere is on the side of the plane the normal is pointing, {Intersect.OUTSIDE} if the entire sphere is on the opposite side, and {Intersect.INTERSETING} if the sphere intersects the plane.

Applies a 4x4 affine transformation matrix to this bounding sphere.

Parameters:
Name Type Argument Description
transform Matrix4 The transformation matrix to apply to the bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
DeveloperError : transform is required.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

Computes a bounding sphere that contains both this bounding sphere and the argument sphere.

Parameters:
Name Type Argument Description
right BoundingSphere The sphere to enclose in this bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
DeveloperError : sphere is required.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Duplicates a BoundingSphere instance.

Parameters:
Name Type Argument Description
sphere BoundingSphere The bounding sphere to duplicate.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
DeveloperError : sphere is required.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Compares the provided BoundingSphere componentwise and returns true if they are equal, false otherwise.

Parameters:
Name Type Argument Description
left BoundingSphere <optional>
The first BoundingSphere.
right BoundingSphere <optional>
The second BoundingSphere.
Returns:
Boolean true if left and right are equal, false otherwise.

<static>

Computes a bounding sphere by enlarging the provided sphere to contain the provided point.

Parameters:
Name Type Argument Description
sphere BoundingSphere A sphere to expand.
point Cartesian3 A point to enclose in a bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Computes a bounding sphere from the corner points of an axis-aligned bounding box. The sphere tighly and fully encompases the box.

Parameters:
Name Type Argument Description
corner Number <optional>
The minimum height over the extent.
oppositeCorner Number <optional>
The maximum height over the extent.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
DeveloperError : corner and oppositeCorner are required.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.
Example
// Create a bounding sphere around the unit cube
var sphere = BoundingSphere.fromCornerPoints(new Cartesian3(-0.5, -0.5, -0.5), new Cartesian3(0.5, 0.5, 0.5));

<static>

Computes a bounding sphere from an extent projected in 2D.

Parameters:
Name Type Argument Default Description
extent Extent The extent around which to create a bounding sphere.
projection Object <optional>
GeographicProjection The projection used to project the extent into 2D.
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Computes a bounding sphere from an extent in 3D. The bounding sphere is created using a subsample of points on the ellipsoid and contained in the extent. It may not be accurate for all extents on all types of ellipsoids.

Parameters:
Name Type Argument Default Description
extent Extent The valid extent used to create a bounding sphere.
ellipsoid Ellipsoid <optional>
Ellipsoid.WGS84 The ellipsoid used to determine positions of the extent.
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Computes a bounding sphere from an extent projected in 2D. The bounding sphere accounts for the object's minimum and maximum heights over the extent.

Parameters:
Name Type Argument Default Description
extent Extent The extent around which to create a bounding sphere.
projection Object <optional>
GeographicProjection The projection used to project the extent into 2D.
minimumHeight Number <optional>
0.0 The minimum height over the extent.
maximumHeight Number <optional>
0.0 The maximum height over the extent.
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Computes a tight-fitting bounding sphere enclosing a list of 3D Cartesian points. 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.

Parameters:
Name Type Argument Description
positions Array An array of points that the bounding sphere will enclose. Each point must have x, y, and z properties.
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if one was not provided.
See:

<static>

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.

Parameters:
Name Type Argument Default Description
positions Array 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 Cartesian3 <optional>
Cartesian3.ZERO 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.
stride Number <optional>
3 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 2. 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.
result BoundingSphere <optional>
The object onto which to store the result.
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if one was not provided.
Example
// 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.
var center = new Cartesian3(1.0, 2.0, 3.0);
var 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];
var sphere = BoundingSphere.fromVertices(points, center, 5);
See:

<static>

The distances calculated by the vector from the center of the bounding sphere to position projected onto direction plus/minus the radius of the bounding sphere.
If you imagine the infinite number of planes with normal direction, this computes the smallest distance to the closest and farthest planes from position that intersect the bounding sphere.

Parameters:
Name Type Argument Description
sphere BoundingSphere The bounding sphere to calculate the distance to.
position Cartesian3 The position to calculate the distance from.
direction Cartesian3 The direction from position.
result Cartesian2 <optional>
A Cartesian2 to store the nearest and farthest distances.
Throws:
Returns:
Interval The nearest and farthest distances on the bounding sphere from position in direction.

<static>

Determines which side of a plane a sphere is located.

Parameters:
Name Type Description
sphere BoundingSphere The bounding sphere to test.
plane Cartesian4 The coefficients of the plane in the for ax + by + cz + d = 0 where the coefficients a, b, c, and d are the components x, y, z, and w of the {Cartesian4}, respectively.
Throws:
Returns:
Intersect {Intersect.INSIDE} if the entire sphere is on the side of the plane the normal is pointing, {Intersect.OUTSIDE} if the entire sphere is on the opposite side, and {Intersect.INTERSETING} if the sphere intersects the plane.

<static>

Applies a 4x4 affine transformation matrix to a bounding sphere.

Parameters:
Name Type Argument Description
sphere BoundingSphere The bounding sphere to apply the transformation to.
transform Matrix4 The transformation matrix to apply to the bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.

<static>

Computes a bounding sphere that contains both the left and right bounding spheres.

Parameters:
Name Type Argument Description
left BoundingSphere A sphere to enclose in a bounding sphere.
right BoundingSphere A sphere to enclose in a bounding sphere.
result BoundingSphere <optional>
The object onto which to store the result.
Throws:
Returns:
BoundingSphere The modified result parameter or a new BoundingSphere instance if none was provided.