Methods
static Cesium.Intersections2D.clipTriangleAtAxisAlignedThreshold(threshold, keepAbove, u0, u1, u2, result) → Array.<number>
在给定轴向对齐的阈值处剖分一个 2D 三角形,并返回阈值给定一侧的结果多边形。结果多边形可能有 0、1、2、3 或 4 个顶点。
| Name | Type | Description |
|---|---|---|
threshold |
number | 用于裁剪三角形的阈值坐标值。 |
keepAbove |
boolean | 为 true 时保留阈值上方的三角形部分,为 false 时保留阈值下方的部分。 |
u0 |
number | 三角形中第一个顶点的坐标,按逆时针顺序。 |
u1 |
number | 三角形中第二个顶点的坐标,按逆时针顺序。 |
u2 |
number | 三角形中第三个顶点的坐标,按逆时针顺序。 |
result |
Array.<number> | optional 用于复制结果的数组。如果未提供此参数, 将构造并返回一个新数组。 |
Returns:
裁剪后得到的结果多边形,以顶点列表的形式给出。顶点按逆时针顺序指定。
每个顶点要么是现有列表中的索引(标识为 0、1 或 2),要么是 -1(表示原始三角形中不存在的新顶点)。
对于新顶点,-1 后面跟着三个附加数字:构成新顶点所在线段的两个原始顶点的索引,
以及从第一个顶点到第二个顶点的距离比例。
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 位置的重心坐标。
| Name | Type | Description |
|---|---|---|
x |
number | 要求重心坐标的位置的 x 坐标。 |
y |
number | 要求重心坐标的位置的 y 坐标。 |
x1 |
number | 三角形第一个顶点的 x 坐标。 |
y1 |
number | 三角形第一个顶点的 y 坐标。 |
x2 |
number | 三角形第二个顶点的 x 坐标。 |
y2 |
number | 三角形第二个顶点的 y 坐标。 |
x3 |
number | 三角形第三个顶点的 x 坐标。 |
y3 |
number | 三角形第三个顶点的 y 坐标。 |
result |
Cartesian3 | optional 用于复制结果的实例。如果此参数 为 undefined,将创建并返回一个新实例。 |
Returns:
三角形内该位置的重心坐标。
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
计算两条线段之间的交点
| Name | Type | Description |
|---|---|---|
x00 |
number | 第一条线第一个顶点的 x 坐标。 |
y00 |
number | 第一条线第一个顶点的 y 坐标。 |
x01 |
number | 第一条线第二个顶点的 x 坐标。 |
y01 |
number | 第一条线第二个顶点的 y 坐标。 |
x10 |
number | 第二条线第一个顶点的 x 坐标。 |
y10 |
number | 第二条线第一个顶点的 y 坐标。 |
x11 |
number | 第二条线第二个顶点的 x 坐标。 |
y11 |
number | 第二条线第二个顶点的 y 坐标。 |
result |
Cartesian2 | optional 用于复制结果的实例。如果此参数 为 undefined,将创建并返回一个新实例。 |
Returns:
交点;如果没有交点或两直线重合,则为 undefined。
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);
