Functions for computing the intersection between geometries such as rays, planes, triangles, and ellipsoids.
Methods
-
Computes the intersection points of a line segment with a sphere.
Name Type Description p0Cartesian3 An end point of the line segment. p1Cartesian3 The other end point of the line segment. sphereBoundingSphere The sphere. resultObject optional The result onto which to store the result. Returns:
An object with the first (start) and the second (stop) intersection scalars for points along the line segment or undefined if there are no intersections. -
staticCesium.IntersectionTests.lineSegmentTriangle(v0, v1, p0, p1, p2, cullBackFaces, result) → Cartesian3
-
Computes the intersection of a line segment and a triangle.
Name Type Default Description v0Cartesian3 The an end point of the line segment. v1Cartesian3 The other end point of the line segment. p0Cartesian3 The first vertex of the triangle. p1Cartesian3 The second vertex of the triangle. p2Cartesian3 The third vertex of the triangle. cullBackFacesBoolean falseoptional If true, will only compute an intersection with the front face of the triangle and return undefined for intersections with the back face.resultCartesian3 optional The Cartesian3onto which to store the result.Returns:
The intersection point or undefined if there is no intersections. -
Computes the intersection points of a ray with a sphere.
Name Type Description rayRay The ray. sphereBoundingSphere The sphere. resultObject optional The result onto which to store the result. Returns:
An object with the first (start) and the second (stop) intersection scalars for points along the ray or undefined if there are no intersections. -
staticCesium.IntersectionTests.rayTriangle(ray, p0, p1, p2, cullBackFaces, result) → Cartesian3
-
Computes the intersection of a ray and a triangle as a Cartesian3 coordinate.
Name Type Default Description rayRay The ray. p0Cartesian3 The first vertex of the triangle. p1Cartesian3 The second vertex of the triangle. p2Cartesian3 The third vertex of the triangle. cullBackFacesBoolean falseoptional If true, will only compute an intersection with the front face of the triangle and return undefined for intersections with the back face.resultCartesian3 optional The Cartesian3onto which to store the result.Returns:
The intersection point or undefined if there is no intersections. -
Computes the intersection of a ray and a triangle as a parametric distance along the input ray.
Name Type Default Description rayRay The ray. p0Cartesian3 The first vertex of the triangle. p1Cartesian3 The second vertex of the triangle. p2Cartesian3 The third vertex of the triangle. cullBackFacesBoolean falseoptional 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. -
staticCesium.IntersectionTests.grazingAltitudeLocation(ray, ellipsoid) → Cartesian3
-
Provides the point along the ray which is nearest to the ellipsoid.
Name Type Description rayRay The ray. ellipsoidEllipsoid The ellipsoid. Returns:
The nearest planetodetic point on the ray. -
staticCesium.IntersectionTests.lineSegmentPlane(endPoint0, endPoint1, plane, result) → Cartesian3
-
Computes the intersection of a line segment and a plane.
Name Type Description endPoint0Cartesian3 An end point of the line segment. endPoint1Cartesian3 The other end point of the line segment. planePlane The plane. resultCartesian3 optional The object onto which to store the result. Returns:
The intersection point or undefined if there is no intersection.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(...); // find the intersection of the line segment from p0 to p1 and the tangent plane at origin. var intersection = Cesium.IntersectionTests.lineSegmentPlane(p0, p1, plane); -
Computes the intersection points of a ray with an ellipsoid.
Name Type Description rayRay The ray. ellipsoidEllipsoid The ellipsoid. Returns:
An object with the first (start) and the second (stop) intersection scalars for points along the ray or undefined if there are no intersections. -
staticCesium.IntersectionTests.rayPlane(ray, plane, result) → Cartesian3
-
Computes the intersection of a ray and a plane.
Name Type Description rayRay The ray. planePlane The plane. resultCartesian3 optional The object onto which to store the result. Returns:
The intersection point or undefined if there is no intersections. -
Computes the intersection of a triangle and a plane
Name Type Description p0Cartesian3 First point of the triangle p1Cartesian3 Second point of the triangle p2Cartesian3 Third point of the triangle planePlane Intersection plane Returns:
An object with propertiespositionsandindices, which are arrays that represent three triangles that do not cross the plane. (Undefined if no intersection exists)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(...); // convert the triangle composed of points (p0, p1, p2) to three triangles that don't cross the plane var triangles = Cesium.IntersectionTests.trianglePlaneIntersection(p0, p1, p2, plane);
