IntersectionTests

用于计算几何体(如射线、平面、三角形和椭球)之间的交集的函数。

Methods

staticCesium.IntersectionTests.grazingAltitudeLocation(ray, ellipsoid)Cartesian3

提供最接近椭球面的射线上的点。
Name Type Description
ray Ray 射线。
ellipsoid Ellipsoid 椭球。
Returns:
射线上最近的行星(planetodetic)点。

staticCesium.IntersectionTests.lineSegmentPlane(endPoint0, endPoint1, plane, result)Cartesian3

计算线段与平面的交点。
Name Type Description
endPoint0 Cartesian3 线段的端点。
endPoint1 Cartesian3 线段的另一端点。
plane Plane 平面。
result Cartesian3 optional 存储结果的对象。
Returns:
交点,如果没有相交,则为undefined。
Example:
var origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
var normal = ellipsoid.geodeticSurfaceNormal(origin);
var plane = Cesium.Plane.fromPointNormal(origin, normal);

var p0 = new Cesium.Cartesian3(...);
var p1 = new Cesium.Cartesian3(...);

// 求出从p0到p1的线段与原点处的切平面的交点。
var intersection = Cesium.IntersectionTests.lineSegmentPlane(p0, p1, plane);

staticCesium.IntersectionTests.lineSegmentSphere(p0, p1, sphere, result)Interval

计算线段与球面的交点。
Name Type Description
p0 Cartesian3 线段的端点。
p1 Cartesian3 线段的另一个端点。
sphere BoundingSphere 球。
result Interval optional 存储结果的对象。
Returns:
沿线段包含标量点的区间,如果没有交点,则为undefined。

staticCesium.IntersectionTests.lineSegmentTriangle(v0, v1, p0, p1, p2, cullBackFaces, result)Cartesian3

计算线段和三角形的交点。
Name Type Default Description
v0 Cartesian3 线段的端点。
v1 Cartesian3 线段的另一端点。
p0 Cartesian3 三角形的第一个顶点。
p1 Cartesian3 三角形的第二个顶点。
p2 Cartesian3 三角形的第三个顶点。
cullBackFaces Boolean false optional 如果true,则只计算与三角形正面的交点,并为背面交点返回undefined。
result Cartesian3 optional 存储结果的Cartesian3
Returns:
交点,如果没有相交,则为undefined。

staticCesium.IntersectionTests.rayEllipsoid(ray, ellipsoid)Interval

计算射线与椭球面的交点。
Name Type Description
ray Ray 射线。
ellipsoid Ellipsoid 椭球。
Returns:
沿射线包含标量点的区间,如果没有交点,则为undefined。

staticCesium.IntersectionTests.rayPlane(ray, plane, result)Cartesian3

计算射线与平面的交点。
Name Type Description
ray Ray 射线。
plane Plane 平面。
result Cartesian3 optional 存储结果的对象。
Returns:
交点,如果没有相交,则为undefined。

staticCesium.IntersectionTests.raySphere(ray, sphere, result)Interval

计算射线与球面的交点。
Name Type Description
ray Ray 射线。
sphere BoundingSphere 球。
result Interval optional 存储结果的对象。
Returns:
沿射线包含标量点的区间,如果没有交点,则为undefined。

staticCesium.IntersectionTests.rayTriangle(ray, p0, p1, p2, cullBackFaces, result)Cartesian3

以Cartesian3坐标计算射线与三角形的交点。 实现Tomas Moller和Ben Trumbore的 Fast Minimum Storage Ray/Triangle Intersection
Name Type Default Description
ray Ray 射线。
p0 Cartesian3 三角形的第一个顶点。
p1 Cartesian3 三角形的第二个顶点。
p2 Cartesian3 三角形的第三个顶点。
cullBackFaces Boolean false optional 如果true,则只计算与三角形正面的交点,并为背面交点返回undefined。
result Cartesian3 optional 存储结果的Cartesian3
Returns:
交点,如果没有相交,则为undefined。

staticCesium.IntersectionTests.rayTriangleParametric(ray, p0, p1, p2, cullBackFaces)Number

计算射线与三角形的交点,作为沿输入射线的参数距离。 实现Tomas Moller和Ben Trumbore的 Fast Minimum Storage Ray/Triangle Intersection
Name Type Default Description
ray Ray 射线。
p0 Cartesian3 三角形的第一个顶点。
p1 Cartesian3 三角形的第二个顶点。
p2 Cartesian3 三角形的第三个顶点。
cullBackFaces Boolean false optional 如果true,则只计算与三角形正面的交点,并为背面交点返回undefined。
Returns:
交点作为沿射线的参数距离,如果没有交点,则为undefined。

staticCesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane)Object

计算三角形与平面的交集。
Name Type Description
p0 Cartesian3 三角形的第一个点。
p1 Cartesian3 三角形的第二个点。
p2 Cartesian3 三角形的第三个点。
plane Plane 交叉平面。
Returns:
一个具有属性positionsindices的对象,这是表示三个不跨越平面的三角形的数组。(如果没有交集,则为undefined)
Example:
var origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
var normal = ellipsoid.geodeticSurfaceNormal(origin);
var plane = Cesium.Plane.fromPointNormal(origin, normal);

var p0 = new Cesium.Cartesian3(...);
var p1 = new Cesium.Cartesian3(...);
var p2 = new Cesium.Cartesian3(...);

// 将由点(p0, p1, p2)组成的三角形转换成三个不穿过平面的三角形
var triangles = Cesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane);