Class: OrientedBoundingBox

OrientedBoundingBox

new OrientedBoundingBox(center, halfAxes)

Create an instance of OrientedFoundingBox. The OrientatedBoundingBox of an object is a closed convex rectangular prism. In many cases, it can provide a tighter bounding box than Boundingsphere or AxisAlignedBoundingBox.

Name Type Default Description
center Cartesian3 Cartesian3.ZERO optional

The center of the enclosure box.

halfAxes Matrix3 Matrix3.ZERO optional

The three orthogonal half axes of the bounding box. Equivalent to a transformation matrix, used for rotating and scaling 2x2 cubes centered at the origin.

See:
Example
// Create an OrientedBoundingBox using a transformation matrix, a position where the box will be translated, and a scale.
var center = new SuperMap3D.Cartesian3(1.0, 0.0, 0.0);
var halfAxes = SuperMap3D.Matrix3.fromScale(new SuperMap3D.Cartesian3(1.0, 3.0, 2.0), new SuperMap3D.Matrix3());

var obb = new SuperMap3D.OrientedBoundingBox(center, halfAxes);

Members

centerCartesian3

The center of the enclosure box.

Default Value:
Cartesian3.ZERO

halfAxesMatrix3

Transform matrix, used to rotate boxes to the correct position.

Default Value:
Matrix3.IDENTITY

Methods

static clone(box, result){OrientedBoundingBox}

Copy the OrientedFoundingBox instance.

Name Type Description
box OrientedBoundingBox

The bounding box to be copied.

result OrientedBoundingBox optional

The object that stores the results.

Returns:
Type Description
OrientedBoundingBox The modified result parameter, or a new OrientedFoundingBox instance (if no OrientedFoundingBox instance is provided, return undefined if box is undefined).

static computePlaneDistances(box, position, direction, result){Interval}

The distance from the center of the bounding box to the projected position in the direction calculated by the vector. Imagine a plane with infinite normal directions, and calculate the minimum distance to the nearest and farthest planes intersecting the bounding box.

Name Type Description
box OrientedBoundingBox

A bounding box used for calculating distance.

position Cartesian3

The position used to calculate distance.

direction Cartesian3

The direction starting from the position.

result Interval optional

Used to store the nearest and farthest time intervals.

Returns:
Type Description
Interval The closest and farthest distances from the position direction on the bounding box.

static distanceSquaredTo(box, cartesian){Number}

Calculate the square of the estimated distance from a point to the nearest point on the bounding box

Name Type Description
box OrientedBoundingBox

box。

cartesian Cartesian3

Point.

Returns:
Type Description
Number The square of the estimated distance from the surrounding sphere to that point.
Example
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return SuperMap3D.OrientedBoundingBox.distanceSquaredTo(b, camera.positionWC) - SuperMap3D.OrientedBoundingBox.distanceSquaredTo(a, camera.positionWC);
});

static equals(left, right){Boolean}

Compare the provided OrientedFoundingBox components and return true if they are equal, otherwise return false.

Name Type Description
left OrientedBoundingBox

The first Oriented BoundingBox.

right OrientedBoundingBox

The second Oriented BoundingBox.

Returns:
Type Description
Boolean If they are equal, it is true; otherwise, it is false.

static fromMapBounds(rectangle, minimumHeight, maximumHeight, ellipsoid, result){OrientedBoundingBox}

Calculate an Oriented BoundingBox on the surface of an Ellipsoid with MapBounds as the boundary.

Name Type Default Description
rectangle MapBounds

Map projection rectangle on the surface of an ellipsoid.

minimumHeight Number 0.0 optional

The lowest height inside the tile (altitude).

maximumHeight Number 0.0 optional

The maximum height inside the tile (altitude).

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

Define the ellipsoid of a rectangle.

result OrientedBoundingBox optional

The object that stores the results.

Throws:
  • Rectangle. width must be between 0 and pi.

    Type
    DeveloperError
  • Rectangle. height must be between 0 and pi.

    Type
    DeveloperError
  • Ellipsoid must be a rotating ellipsoid (radii. x==radii. y)

    Type
    DeveloperError
Returns:
Type Description
OrientedBoundingBox The modified result parameters, or a new OrientedFoundingBox instance (if not provided).

static fromPoints(positions, result){OrientedBoundingBox}

Compute an OrientedFoundingBox instance at a given location. This is the implementation of Stefan Gottschalk's collision query using bounding box solution (doctoral thesis). reference resources: http://gamma.cs.unc.edu/users/gottschalk/main.pdf

Name Type Description
positions Array.<Cartesian3>

A set of Cartesian 3-point points within a bounding box.

result OrientedBoundingBox optional

The object that stores the results.

Returns:
Type Description
OrientedBoundingBox The modified result parameters, or a new OrientedFoundingBox instance (if not provided).
Example
// Compute an object oriented bounding box enclosing two points.
var box = SuperMap3D.OrientedBoundingBox.fromPoints([new SuperMap3D.Cartesian3(2, 0, 0), new SuperMap3D.Cartesian3(-2, 0, 0)]);

static fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid, result){OrientedBoundingBox}

Calculate an Oriented BoundingBox with Rectangle as the boundary on the surface of an Ellipsoid.

Name Type Default Description
rectangle Rectangle

Map projection rectangle on the surface of an ellipsoid.

minimumHeight Number 0.0 optional

The lowest height inside the tile (altitude).

maximumHeight Number 0.0 optional

The maximum height inside the tile (altitude).

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

Define the ellipsoid of a rectangle.

result OrientedBoundingBox optional

The object that stores the results.

Throws:
  • Rectangle. width must be between 0 and pi.

    Type
    DeveloperError
  • Rectangle. height must be between 0 and pi.

    Type
    DeveloperError
  • Ellipsoid must be a rotating ellipsoid (radii. x==radii. y)

    Type
    DeveloperError
Returns:
Type Description
OrientedBoundingBox The modified result parameters, or a new OrientedFoundingBox instance (if not provided).

static intersectPlane(box, plane){Intersect}

Determine which side of the plane the directional bounding box is located on.

Name Type Description
box OrientedBoundingBox

The directional bounding box to be tested.

plane Plane

The plane to be tested.

Returns:
Type Description
Intersect Intersect.INSIDE indicates that the entire box is located on one side of the plane pointed to by the normal; Intersection. OUT indicates that the entire box is located on the other side of the plane; Intersect.INTERSECTING means that the box intersects with the plane.

static isOccluded(box, occluder){Boolean}

Determine if the bounding box is hidden by any obstructions.

Name Type Description
box OrientedBoundingBox

The bounding box around the occluded object.

occluder Occluder

Obstructive object.

Returns:
Type Description
Boolean If the box is not visible, it is true; Otherwise, it is false.

clone(result){OrientedBoundingBox}

Copy this OrientedFoundingBox instance.

Name Type Description
result OrientedBoundingBox optional

The object that stores the results.

Returns:
Type Description
OrientedBoundingBox The modified result parameters or a new OrientedFoundingBox instance (if not provided).

computePlaneDistances(position, direction, result){Interval}

The distance calculated from the center of the bounding box to the position projected in the direction. Imagine a plane with infinite normal directions, which will calculate the minimum distance to the nearest and farthest planes intersecting the bounding box.

Name Type Description
position Cartesian3

To calculate the location of the distance.

direction Cartesian3

The direction starting from the position.

result Interval optional

Used to store the nearest and farthest time intervals.

Returns:
Type Description
Interval The closest and farthest distances from position to direction on the bounding box.

distanceSquaredTo(cartesian){Number}

Calculate the square of the estimated distance from the nearest point to the point in the bounding box.

Name Type Description
cartesian Cartesian3

Point.

Returns:
Type Description
Number The estimated distance square from the enclosing sphere to the point.
Example
// Sort bounding boxes from back to front
boxes.sort(function(a, b) {
    return b.distanceSquaredTo(camera.positionWC) - a.distanceSquaredTo(camera.positionWC);
});

equals(right){Boolean}

Compare this OrientedFoundingBox with the provided OrientedFoundingBox component, return true if they are equal, otherwise return false.

Name Type Description
right OrientedBoundingBox optional

The Oriented BoundingBox on the right.

Returns:
Type Description
Boolean If they are equal, it is true; otherwise, it is false.

intersectPlane(plane){Intersect}

Determine which side of the plane the directional bounding box is located on.

Name Type Description
plane Plane

The plane to be tested.

Returns:
Type Description
Intersect Intersect.INSIDE indicates that the entire box is located on one side of the plane pointed to by the normal; Intersection. OUT indicates that the entire box is located on the other side of the plane; Intersect.INTERSECTING means that the box intersects with the plane.

isOccluded(occluder){Boolean}

Determine if the bounding box is hidden by any obstructions.

Name Type Description
occluder Occluder

Obstructive object.

Returns:
Type Description
Boolean If the box is not visible, it is true; Otherwise, it is false.