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:
-
- BoundingSphere
- BoundingRectangle
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.IDENTITYMethods
-
static clone(box, result){OrientedBoundingBox}
-
Copy the OrientedFoundingBox instance.
Name Type Description boxOrientedBoundingBox The bounding box to be copied.
resultOrientedBoundingBox 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 boxOrientedBoundingBox A bounding box used for calculating distance.
positionCartesian3 The position used to calculate distance.
directionCartesian3 The direction starting from the position.
resultInterval 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 boxOrientedBoundingBox box。
cartesianCartesian3 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 leftOrientedBoundingBox The first Oriented BoundingBox.
rightOrientedBoundingBox 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 rectangleMapBounds Map projection rectangle on the surface of an ellipsoid.
minimumHeightNumber 0.0 optional The lowest height inside the tile (altitude).
maximumHeightNumber 0.0 optional The maximum height inside the tile (altitude).
ellipsoidEllipsoid Ellipsoid.WGS84 optional Define the ellipsoid of a rectangle.
resultOrientedBoundingBox 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 positionsArray.<Cartesian3> A set of Cartesian 3-point points within a bounding box.
resultOrientedBoundingBox 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 rectangleRectangle Map projection rectangle on the surface of an ellipsoid.
minimumHeightNumber 0.0 optional The lowest height inside the tile (altitude).
maximumHeightNumber 0.0 optional The maximum height inside the tile (altitude).
ellipsoidEllipsoid Ellipsoid.WGS84 optional Define the ellipsoid of a rectangle.
resultOrientedBoundingBox 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 boxOrientedBoundingBox The directional bounding box to be tested.
planePlane 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 boxOrientedBoundingBox The bounding box around the occluded object.
occluderOccluder 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 resultOrientedBoundingBox 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 positionCartesian3 To calculate the location of the distance.
directionCartesian3 The direction starting from the position.
resultInterval 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 cartesianCartesian3 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 rightOrientedBoundingBox 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 planePlane 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 occluderOccluder Obstructive object.
Returns:
Type Description Boolean If the box is not visible, it is true; Otherwise, it is false.