包含用于操作 2D 三角形的函数。 Contains functions for operating on 2D triangles.
方法 Methods
static Cesium.Intersections2D.clipTriangleAtAxisAlignedThreshold(threshold, keepAbove, u0, u1, u2, result) → Array.<number>
在给定的轴对齐阈值处分割 2D 三角形,并返回阈值给定边上的结果多边形。生成的多边形可能有 0、1、2、3 或 4 个顶点。 Splits a 2D triangle at given axis-aligned threshold value and returns the resulting polygon on a given side of the threshold. The resulting polygon may have 0, 1, 2, 3, or 4 vertices.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
threshold |
number | 裁剪三角形的阈值坐标值。 The threshold coordinate value at which to clip the triangle. |
keepAbove |
boolean | 如果为 true,则将三角形的部分保持在阈值以上;如果为 false,则将三角形的部分保持在阈值以下。 true to keep the portion of the triangle above the threshold, or false to keep the portion below. |
u0 |
number | 三角形中第一个顶点的坐标,按逆时针顺序排列。 The coordinate of the first vertex in the triangle, in counter-clockwise order. |
u1 |
number | 三角形中第二个顶点的坐标,按逆时针顺序排列。 The coordinate of the second vertex in the triangle, in counter-clockwise order. |
u2 |
number | 三角形中第三个顶点的坐标,按逆时针顺序排列。 The coordinate of the third vertex in the triangle, in counter-clockwise order. |
result |
Array.<number> | 可选 optional 将结果复制到的数组。如果未提供此参数,则构造并返回一个新数组。 The array into which to copy the result. If this parameter is not supplied, a new array is constructed and returned. |
返回: Returns:
剪辑后生成的多边形,指定为顶点列表。顶点按逆时针顺序指定。每个顶点要么是现有列表中的索引(标识为 0、1 或 2),要么是 -1(表示不在原始三角形中的新顶点)。对于新顶点,-1 后面跟着三个附加数字:形成新顶点所在线段的两个原始顶点中每个顶点的索引,以及从第一个顶点到第二个顶点的距离的分数。 The polygon that results after the clip, specified as a list of vertices. The vertices are specified in counter-clockwise order. Each vertex is either an index from the existing list (identified as a 0, 1, or 2) or -1 indicating a new vertex not in the original triangle. For new vertices, the -1 is followed by three additional numbers: the index of each of the two original vertices forming the line segment that the new vertex lies on, and the fraction of the distance from the first vertex to the second one.
示例: Example:
const result = Cesium.Intersections2D.clipTriangleAtAxisAlignedThreshold(0.5, false, 0.2, 0.6, 0.4);
// result === [2, 0, -1, 1, 0, 0.25, -1, 1, 2, 0.5]
static Cesium.Intersections2D.computeBarycentricCoordinates(x, y, x1, y1, x2, y2, x3, y3, result) → Cartesian3
计算 2D 三角形内 2D 位置的重心坐标。 Compute the barycentric coordinates of a 2D position within a 2D triangle.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x |
number | 要查找重心坐标的位置的 x 坐标。 The x coordinate of the position for which to find the barycentric coordinates. |
y |
number | 要查找重心坐标的位置的 y 坐标。 The y coordinate of the position for which to find the barycentric coordinates. |
x1 |
number | 三角形第一个顶点的 x 坐标。 The x coordinate of the triangle's first vertex. |
y1 |
number | 三角形第一个顶点的 y 坐标。 The y coordinate of the triangle's first vertex. |
x2 |
number | 三角形第二个顶点的 x 坐标。 The x coordinate of the triangle's second vertex. |
y2 |
number | 三角形第二个顶点的 y 坐标。 The y coordinate of the triangle's second vertex. |
x3 |
number | 三角形第三个顶点的 x 坐标。 The x coordinate of the triangle's third vertex. |
y3 |
number | 三角形第三个顶点的 y 坐标。 The y coordinate of the triangle's third vertex. |
result |
Cartesian3 | 可选 optional 将结果复制到的实例。如果该参数未定义,则创建并返回一个新实例。 The instance into to which to copy the result. If this parameter is undefined, a new instance is created and returned. |
返回: Returns:
三角形内位置的重心坐标。 The barycentric coordinates of the position within the triangle.
示例: Example:
const result = Cesium.Intersections2D.computeBarycentricCoordinates(0.0, 0.0, 0.0, 1.0, -1, -0.5, 1, -0.5);
// result === new Cesium.Cartesian3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0);
static Cesium.Intersections2D.computeLineSegmentLineSegmentIntersection(x00, y00, x01, y01, x10, y10, x11, y11, result) → Cartesian2
计算两条线段之间的交点 Compute the intersection between 2 line segments
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x00 |
number | 第一条线的第一个顶点的 x 坐标。 The x coordinate of the first line's first vertex. |
y00 |
number | 第一条线的第一个顶点的 y 坐标。 The y coordinate of the first line's first vertex. |
x01 |
number | 第一条线的第二个顶点的 x 坐标。 The x coordinate of the first line's second vertex. |
y01 |
number | 第一条线的第二个顶点的 y 坐标。 The y coordinate of the first line's second vertex. |
x10 |
number | 第二条线的第一个顶点的 x 坐标。 The x coordinate of the second line's first vertex. |
y10 |
number | 第二条线的第一个顶点的 y 坐标。 The y coordinate of the second line's first vertex. |
x11 |
number | 第二条线的第二个顶点的 x 坐标。 The x coordinate of the second line's second vertex. |
y11 |
number | 第二条线的第二个顶点的 y 坐标。 The y coordinate of the second line's second vertex. |
result |
Cartesian2 | 可选 optional 将结果复制到的实例。如果该参数未定义,则创建并返回一个新实例。 The instance into to which to copy the result. If this parameter is undefined, a new instance is created and returned. |
返回: Returns:
交点,如果没有交点或线重合,则未定义。 The intersection point, undefined if there is no intersection point or lines are coincident.
示例: Example:
const result = Cesium.Intersections2D.computeLineSegmentLineSegmentIntersection(0.0, 0.0, 0.0, 2.0, -1, 1, 1, 1);
// result === new Cesium.Cartesian2(0.0, 1.0);
