Hermite 样条是三次插值样条。点、传入切线、传出切线和时间
必须为每个控制点定义。传出切线是为点 [0, n - 2] 定义的,传入的
为点 [1, n - 1] 定义切线。例如,在
点 [i]
和
points[i + 1]
,则点处的切线将为 outTangents[i]
和 inTangents[i]
,
分别。
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
对象,具有以下属性:
|
Throws:
-
DeveloperError : points.length must be greater than or equal to 2.
-
DeveloperError : times.length must be equal to points.length.
-
DeveloperError : inTangents and outTangents must have a length equal to points.length - 1.
-
DeveloperError : inTangents and outTangents must be of the same type as points.
Example:
// Create a G<sup>1</sup> continuous Hermite spline
const times = [ 0.0, 1.5, 3.0, 4.5, 6.0 ];
const spline = new Cesium.HermiteSpline({
times : times,
points : [
new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0)
],
outTangents : [
new Cesium.Cartesian3(1125196, -161816, 270551),
new Cesium.Cartesian3(-996690.5, -365906.5, 184028.5),
new Cesium.Cartesian3(-2096917, 48379.5, -292683.5),
new Cesium.Cartesian3(-890902.5, 408999.5, -447115)
],
inTangents : [
new Cesium.Cartesian3(-1993381, -731813, 368057),
new Cesium.Cartesian3(-4193834, 96759, -585367),
new Cesium.Cartesian3(-1781805, 817999, -894230),
new Cesium.Cartesian3(1165345, 112641, 47281)
]
});
const p0 = spline.evaluate(times[0]);
See:
Members
readonly inTangents : Array.<Cartesian3>
每个控制点处的传入切线数组。
readonly outTangents : Array.<Cartesian3>
每个控制点处的传出切线数组。
readonly points : Array.<Cartesian3>
控制点数组。
控制点的时间数组。
Methods
static Cesium.HermiteSpline.createC1(options) → HermiteSpline
创建每个控制点处的切线相同的样条曲线。
保证曲线至少在类中 C1.
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
对象,具有以下属性:
|
Returns:
隐士样条。
Throws:
-
DeveloperError : points, times and tangents are required.
-
DeveloperError : points.length must be greater than or equal to 2.
-
DeveloperError : times, points and tangents must have the same length.
Example:
const points = [
new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0)
];
// Add tangents
const tangents = new Array(points.length);
tangents[0] = new Cesium.Cartesian3(1125196, -161816, 270551);
const temp = new Cesium.Cartesian3();
for (let i = 1; i < tangents.length - 1; ++i) {
tangents[i] = Cesium.Cartesian3.multiplyByScalar(Cesium.Cartesian3.subtract(points[i + 1], points[i - 1], temp), 0.5, new Cesium.Cartesian3());
}
tangents[tangents.length - 1] = new Cesium.Cartesian3(1165345, 112641, 47281);
const spline = Cesium.HermiteSpline.createC1({
times : times,
points : points,
tangents : tangents
});
static Cesium.HermiteSpline.createClampedCubic(options) → HermiteSpline|LinearSpline
创建钳制的三次样条线。生成内部控制点处的切线
在类 C2 中创建曲线。
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
对象,具有以下属性:
|
Returns:
隐蔽样条曲线,如果给出的控制点少于 3 个,则为线性样条曲线。
Throws:
-
DeveloperError : points, times, firstTangent and lastTangent are required.
-
DeveloperError : points.length must be greater than or equal to 2.
-
DeveloperError : times.length must be equal to points.length.
-
DeveloperError : firstTangent and lastTangent must be of the same type as points.
Example:
// Create a clamped cubic spline above the earth from Philadelphia to Los Angeles.
const spline = Cesium.HermiteSpline.createClampedCubic({
times : [ 0.0, 1.5, 3.0, 4.5, 6.0 ],
points : [
new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0)
],
firstTangent : new Cesium.Cartesian3(1125196, -161816, 270551),
lastTangent : new Cesium.Cartesian3(1165345, 112641, 47281)
});
static Cesium.HermiteSpline.createNaturalCubic(options) → HermiteSpline|LinearSpline
创建自然的三次样条线。将生成控制点处的切线
在类 C2 中创建曲线。
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
对象,具有以下属性:
|
Returns:
隐蔽样条曲线,如果给出的控制点少于 3 个,则为线性样条曲线。
Throws:
-
DeveloperError : points and times are required.
-
DeveloperError : points.length must be greater than or equal to 2.
-
DeveloperError : times.length must be equal to points.length.
Example:
// Create a natural cubic spline above the earth from Philadelphia to Los Angeles.
const spline = Cesium.HermiteSpline.createNaturalCubic({
times : [ 0.0, 1.5, 3.0, 4.5, 6.0 ],
points : [
new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0)
]
});
将给定时间限制为样条所覆盖的时间段。
Name | Type | Description |
---|---|---|
time |
number | 时间。 |
Returns:
时间,固定到动画周期。
evaluate(time, result) → Cartesian3
在给定时间计算曲线。
Name | Type | Description |
---|---|---|
time |
number | 评估曲线的时间。 |
result |
Cartesian3 | optional 要在其上存储结果的对象。 |
Returns:
修改后的结果参数 或给定时间曲线上点的新实例。
Throws:
-
DeveloperError : time must be in the range
[t0, tn]
, wheret0
is the first element in the arraytimes
andtn
is the last element in the arraytimes
.
在
times
中查找索引 i
,使得参数
times
在区间 [times[i], times[i + 1]]
中。
Name | Type | Description |
---|---|---|
time |
number | 时间。 |
Returns:
区间开始时元素的索引。
Throws:
-
DeveloperError : time must be in the range
[t0, tn]
, wheret0
is the first element in the arraytimes
andtn
is the last element in the arraytimes
.
将给定时间环绕到样条所覆盖的时间段。
Name | Type | Description |
---|---|---|
time |
number | 时间。 |
Returns:
时间,环绕到更新的动画。