new OrientedBoundingBox(center, halfAxes)
创建 OrientedBoundingBox 的实例。某个对象的 OrientedBoundingBox 是一个封闭的凸长方体。在许多情况下,它可以提供比 BoundingSphere或AxisAlignedBoundingBox更紧密的包围盒。
| Name | Type | Default | Description |
|---|---|---|---|
center |
Cartesian3 | Cartesian3.ZERO |
可选
包围盒的中心。 |
halfAxes |
Matrix3 | Matrix3.ZERO |
可选
包围盒的三个正交半轴。等价于转换矩阵,用于旋转和缩放以原点为中心的 2x2x2 立方体。 |
- 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
-
包围盒的中心。
- Default Value:
Cartesian3.ZERO
halfAxesMatrix3
转换矩阵,用于将方框旋转到正确的位置。
- Default Value:
Matrix3.IDENTITYMethods
-
static clone(box, result){OrientedBoundingBox}
-
复制 OrientedBoundingBox 实例。
Name Type Description boxOrientedBoundingBox 要复制的包围盒。
resultOrientedBoundingBox 可选 存储结果的对象。
Returns:
Type Description OrientedBoundingBox 修改后的结果参数,或一个新的 OrientedBoundingBox 实例(如果没有提供任何 OrientedBoundingBox 实例,如果box未定义,则返回未定义)。 -
static computePlaneDistances(box, position, direction, result){Interval}
-
由矢量计算的从包围盒中心到投影到方向上的位置的距离。
想象有无限个法线方向的平面,将计算到与包围盒相交位置最近和最远的平面的最小距离。Name Type Description boxOrientedBoundingBox 用于计算距离的包围盒。
positionCartesian3 用于计算距离的位置。
directionCartesian3 从位置开始的方向。
resultInterval 可选 用于存储最近和最远距离的时间间隔。
Returns:
Type Description Interval 包围盒上距离位置方向最近和最远的距离。 -
static distanceSquaredTo(box, cartesian){Number}
-
计算从点到bounding box上最近点的估计距离的平方
Name Type Description boxOrientedBoundingBox box。
cartesianCartesian3 点。
Returns:
Type Description Number 从包围球到该点的估计距离的平方。 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}
-
比较提供的 OrientedBoundingBox 组件,如果它们相等则返回 true ,否则返回 false 。
Name Type Description leftOrientedBoundingBox 第一个 OrientedBoundingBox。
rightOrientedBoundingBox 第二个OrientedBoundingBox。
Returns:
Type Description Boolean 如果相等,则为 true ,否则为 false 。 -
static fromPoints(positions, result){OrientedBoundingBox}
-
计算给定位置的一个OrientedBoundingBox实例。这是Stefan Gottschalk的碰撞查询使用包围盒解决方案(博士论文)的实现。参考:http://gamma.cs.unc.edu/users/gottschalk/main.pdf
Name Type Description positionsArray.<Cartesian3> 一组在包围盒内的
Cartesian3点集。resultOrientedBoundingBox 可选 存储结果的对象。
Returns:
Type Description OrientedBoundingBox 修改后的结果参数,或者一个新的 OrientedBoundingBox 实例(如果没有提供)。 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}
-
Name Type Default Description rectangleRectangle 椭球体表面的地图投影矩形。
minimumHeightNumber 0.0 可选 瓦片内的最低高度(海拔高度)。
maximumHeightNumber 0.0 可选 瓦片内的最大高度(海拔高度)。
ellipsoidEllipsoid Ellipsoid.WGS84 可选 定义矩形的椭圆体。
resultOrientedBoundingBox 可选 存储结果的对象。
Throws:
-
-
rectangle.width 必须介于 0 和 pi 之间。
- Type
- DeveloperError
-
-
-
rectangle.height 必须介于 0 和 pi 之间。
- Type
- DeveloperError
-
-
-
ellipsoid 必须是一个旋转的椭圆体 (radii.x == radii.y)
- Type
- DeveloperError
-
Returns:
Type Description OrientedBoundingBox 修改后的结果参数,或者一个新的 OrientedBoundingBox 实例(如果没有提供)。 -
-
static intersectPlane(box, plane){Intersect}
-
确定定向包围盒位于平面的哪侧。
Name Type Description boxOrientedBoundingBox 要测试的定向包围盒。
planePlane 要测试的平面。
Returns:
Type Description Intersect Intersect.INSIDE表示整个box位于法线指向的平面一侧;Intersect.OUTSIDE表示整个box位于平面的另一侧;Intersect.INTERSECTING表示box与平面相交。 -
static isOccluded(box, occluder){Boolean}
-
确定包围盒是否被遮挡物隐藏。
Name Type Description boxOrientedBoundingBox 被遮挡物体周围的包围盒。
occluderOccluder 遮挡物。
Returns:
Type Description Boolean 如果box不可见,则为 true;否则为 false。 -
clone(result){OrientedBoundingBox}
-
复制此 OrientedBoundingBox 实例。
Name Type Description resultOrientedBoundingBox 可选 存储结果的对象。
Returns:
Type Description OrientedBoundingBox 修改后的结果参数或新的 OrientedBoundingBox 实例(如果未提供)。 -
computePlaneDistances(position, direction, result){Interval}
-
从bounding box中心到投射到方向上的位置的矢量计算出的距离。
想象有无限个法线方向的平面,这将计算到与bounding box相交位置最近和最远的平面的最小距离。Name Type Description positionCartesian3 要计算距离的位置。
directionCartesian3 从位置开始的方向。
resultInterval 可选 用于存储最近和最远距离的时间间隔。
Returns:
Type Description Interval bounding box上从位置到方向的最近和最远距离。 -
distanceSquaredTo(cartesian){Number}
-
计算bounding box中最近点到点的估计距离平方。
Name Type Description cartesianCartesian3 点。
Returns:
Type Description Number 从包围球到点的估计距离平方。 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}
-
将此 OrientedBoundingBox 与提供的 OrientedBoundingBox 组件进行比较,如果它们相等则返回 true ,否则返回 false 。
Name Type Description rightOrientedBoundingBox 可选 右侧的OrientedBoundingBox。
Returns:
Type Description Boolean 如果它们相等,则为 true ,否则为 false 。 -
intersectPlane(plane){Intersect}
-
确定定向包围盒位于平面的哪一侧。
Name Type Description planePlane 要测试的平面。
Returns:
Type Description Intersect Intersect.INSIDE表示整个box位于法线指向的平面一侧;Intersect.OUTSIDE表示整个box位于平面的另一侧;Intersect.INTERSECTING表示box与平面相交。 -
isOccluded(occluder){Boolean}
-
确定包围盒是否被遮挡物隐藏。
Name Type Description occluderOccluder 遮挡物。
Returns:
Type Description Boolean 如果box不可见,则为 true;否则为 false。