English中文

IntersectionTests

用于计算射线、平面、三角形和椭球体等几何图形之间的交集的函数。 Functions for computing the intersection between geometries such as rays, planes, triangles, and ellipsoids.

方法 Methods

static Cesium.IntersectionTests.grazingAltitudeLocation(ray, ellipsoid)Cartesian3

提供沿射线最接近椭球体的点。 Provides the point along the ray which is nearest to the ellipsoid.
名称 Name 类型 Type 说明 Description
ray Ray 射线。 The ray.
ellipsoid Ellipsoid 椭球体。 The ellipsoid.
返回: Returns:
射线上最近的行星测量点。 The nearest planetodetic point on the ray.

static Cesium.IntersectionTests.lineSegmentPlane(endPoint0, endPoint1, plane, result)Cartesian3

计算线段和平面的交集。 Computes the intersection of a line segment and a plane.
名称 Name 类型 Type 说明 Description
endPoint0 Cartesian3 线段的端点。 An end point of the line segment.
endPoint1 Cartesian3 线段的另一个端点。 The other end point of the line segment.
plane Plane 飞机。 The plane.
result Cartesian3 可选 optional 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
如果没有交点,则交点或未定义。 The intersection point or undefined if there is no intersection.
示例: Example:
const origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
const normal = ellipsoid.geodeticSurfaceNormal(origin);
const plane = Cesium.Plane.fromPointNormal(origin, normal);

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

// find the intersection of the line segment from p0 to p1 and the tangent plane at origin.
const intersection = Cesium.IntersectionTests.lineSegmentPlane(p0, p1, plane);

static Cesium.IntersectionTests.lineSegmentSphere(p0, p1, sphere, result)Interval

计算线段与球体的交点。 Computes the intersection points of a line segment with a sphere.
名称 Name 类型 Type 说明 Description
p0 Cartesian3 线段的端点。 An end point of the line segment.
p1 Cartesian3 线段的另一个端点。 The other end point of the line segment.
sphere BoundingSphere 球体。 The sphere.
result Interval 可选 optional 用于存储结果的结果。 The result onto which to store the result.
返回: Returns:
包含沿射线的标量点的区间,如果没有交点则未定义。 The interval containing scalar points along the ray or undefined if there are no intersections.

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

计算线段和三角形的交点。 Computes the intersection of a line segment and a triangle.
名称 Name 类型 Type 默认值 Default 说明 Description
v0 Cartesian3 线段的端点。 The an end point of the line segment.
v1 Cartesian3 线段的另一个端点。 The other end point of the line segment.
p0 Cartesian3 三角形的第一个顶点。 The first vertex of the triangle.
p1 Cartesian3 三角形的第二个顶点。 The second vertex of the triangle.
p2 Cartesian3 三角形的第三个顶点。 The third vertex of the triangle.
cullBackFaces boolean false 可选 optional If true,将仅计算与三角形正面的交集,并对于与背面的交集返回未定义。 , will only compute an intersection with the front face of the triangle and return undefined for intersections with the back face.
result Cartesian3 可选 optional The Cartesian3 用于存储结果的。 onto which to store the result.
返回: Returns:
如果没有交点,则交点或未定义。 The intersection point or undefined if there is no intersections.

static Cesium.IntersectionTests.rayAxisAlignedBoundingBox(ray, box, result)

计算射线与轴对齐边界框的交点。 (轴与射线在同一空间中对齐) Computes the intersection points of a ray with an axis-aligned bounding box. (axis-aligned in the same space as the ray)
名称 Name 类型 Type 说明 Description
ray Ray 射线。 The ray.
box AxisAlignedBoundingBox 轴对齐的边界框。 The axis-aligned bounding box.
result Interval | undefined 包含沿射线的标量点的区间,如果没有交点则未定义。 The interval containing scalar points along the ray or undefined if there are no intersections.

static Cesium.IntersectionTests.rayEllipsoid(ray, ellipsoid)Interval

计算射线与椭球体的交点。 Computes the intersection points of a ray with an ellipsoid.
名称 Name 类型 Type 说明 Description
ray Ray 射线。 The ray.
ellipsoid Ellipsoid 椭球体。 The ellipsoid.
返回: Returns:
包含沿射线的标量点的区间,如果没有交点则未定义。 The interval containing scalar points along the ray or undefined if there are no intersections.

static Cesium.IntersectionTests.rayPlane(ray, plane, result)Cartesian3

计算射线和平面的交集。 Computes the intersection of a ray and a plane.
名称 Name 类型 Type 说明 Description
ray Ray 射线。 The ray.
plane Plane 飞机。 The plane.
result Cartesian3 可选 optional 用于存储结果的对象。 The object onto which to store the result.
返回: Returns:
如果没有交点,则交点或未定义。 The intersection point or undefined if there is no intersections.

static Cesium.IntersectionTests.raySphere(ray, sphere, result)Interval

计算射线与球体的交点。 Computes the intersection points of a ray with a sphere.
名称 Name 类型 Type 说明 Description
ray Ray 射线。 The ray.
sphere BoundingSphere 球体。 The sphere.
result Interval 可选 optional 用于存储结果的结果。 The result onto which to store the result.
返回: Returns:
包含沿射线的标量点的区间,如果没有交点则未定义。 The interval containing scalar points along the ray or undefined if there are no intersections.

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

计算射线和三角形的交集作为笛卡尔 3 坐标。实现{@link https://cadxfem.org/inf/Fast MinimStorage RayTriangle Intersection.pdf|快速最小存储射线/三角形交集},作者:Tomas Moller 和 Ben Trumbore。 Computes the intersection of a ray and a triangle as a Cartesian3 coordinate. Implements {@link https://cadxfem.org/inf/Fast MinimumStorage RayTriangle Intersection.pdf| Fast Minimum Storage Ray/Triangle Intersection} by Tomas Moller and Ben Trumbore.
名称 Name 类型 Type 默认值 Default 说明 Description
ray Ray 射线。 The ray.
p0 Cartesian3 三角形的第一个顶点。 The first vertex of the triangle.
p1 Cartesian3 三角形的第二个顶点。 The second vertex of the triangle.
p2 Cartesian3 三角形的第三个顶点。 The third vertex of the triangle.
cullBackFaces boolean false 可选 optional If true,将仅计算与三角形正面的交集,并对于与背面的交集返回未定义。 , will only compute an intersection with the front face of the triangle and return undefined for intersections with the back face.
result Cartesian3 可选 optional The Cartesian3 用于存储结果的。 onto which to store the result.
返回: Returns:
如果没有交点,则交点或未定义。 The intersection point or undefined if there is no intersections.

static Cesium.IntersectionTests.rayTriangleParametric(ray, p0, p1, p2, cullBackFaces)number

计算射线和三角形的交集作为沿输入射线的参数距离。当三角形位于射线后面时,结果为负。实现{@link https://cadxfem.org/inf/Fast MinimStorage RayTriangle Intersection.pdf|快速最小存储射线/三角形交集},作者:Tomas Moller 和 Ben Trumbore。 Computes the intersection of a ray and a triangle as a parametric distance along the input ray. The result is negative when the triangle is behind the ray. Implements {@link https://cadxfem.org/inf/Fast MinimumStorage RayTriangle Intersection.pdf| Fast Minimum Storage Ray/Triangle Intersection} by Tomas Moller and Ben Trumbore.
名称 Name 类型 Type 默认值 Default 说明 Description
ray Ray 射线。 The ray.
p0 Cartesian3 三角形的第一个顶点。 The first vertex of the triangle.
p1 Cartesian3 三角形的第二个顶点。 The second vertex of the triangle.
p2 Cartesian3 三角形的第三个顶点。 The third vertex of the triangle.
cullBackFaces boolean false 可选 optional If true,将仅计算与三角形正面的交集,并对于与背面的交集返回未定义。 , will only compute an intersection with the front face of the triangle and return undefined for intersections with the back face.
返回: Returns:
交点作为沿射线的参数距离,如果没有交点则未定义。 The intersection as a parametric distance along the ray, or undefined if there is no intersection.

static Cesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane)object

计算三角形和平面的交集 Computes the intersection of a triangle and a plane
名称 Name 类型 Type 说明 Description
p0 Cartesian3 三角形的第一点 First point of the triangle
p1 Cartesian3 三角形的第二个点 Second point of the triangle
p2 Cartesian3 三角形的第三点 Third point of the triangle
plane Plane 相交平面 Intersection plane
返回: Returns:
具有属性的对象 An object with properties positions and indices,它们是表示不穿过平面的三个三角形的数组。 (如果不存在交集,则未定义) , which are arrays that represent three triangles that do not cross the plane. (Undefined if no intersection exists)
示例: Example:
const origin = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
const normal = ellipsoid.geodeticSurfaceNormal(origin);
const plane = Cesium.Plane.fromPointNormal(origin, normal);

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

// convert the triangle composed of points (p0, p1, p2) to three triangles that don't cross the plane
const triangles = Cesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane);
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.