Hermite样条是三次插值样条。点、传入切线、传出切线和时间
必须为每个控制点定义。出切线是为点[0,n-2]和传入切线定义的
为点[1,n-1]定义切线。例如,在
points[i]
和
61168和61166的切线是,
分别。Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 具有以下属性的对象:
|
Throws:
-
DeveloperError : 点.长度必须大于或等于2。
-
DeveloperError : 时间长度必须等于点.长度.
-
DeveloperError :入切线和出切线的长度必须等于点.长度-1。
Example:
// Create a G<sup>1</sup> continuous Hermite spline
var times = [ 0.0, 1.5, 3.0, 4.5, 6.0 ];
var 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)
]
});
var p0 = spline.evaluate(times[0]);
See:
Members
readonly inTangents : Array.<Cartesian3>
每个控制点的
Cartesian3
个传入切线的数组。readonly outTangents : Array.<Cartesian3>
在每个控制点有
Cartesian3
个出切线的数组。readonly points : Array.<Cartesian3>
由
Cartesian3
个控制点组成的数组。控制点的时间数组。
Methods
static Cesium.HermiteSpline.createC1(options) → HermiteSpline
创建一条样条曲线,其中每个控制点的切线相同。
保证曲线至少为C1级。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | 具有以下属性的对象:
|
Returns:
埃尔米特样条线。
Throws:
-
DeveloperError :需要点、时间和切线。
-
DeveloperError : 点.长度必须大于或等于2。
-
DeveloperError :时间、点和切线的长度必须相同。
Example:
var 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
var tangents = new Array(points.length);
tangents[0] = new Cesium.Cartesian3(1125196, -161816, 270551);
var temp = new Cesium.Cartesian3();
for (var 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);
var 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个,则采用hermite样条或线性样条。
Throws:
-
DeveloperError :点、时间、firstTangent和lastTangent是必需的。
-
DeveloperError : 点.长度必须大于或等于2。
-
DeveloperError : 时间长度必须等于点.长度.
Example:
// Create a clamped cubic spline above the earth from Philadelphia to Los Angeles.
var 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个,则采用hermite样条或线性样条。
Throws:
-
DeveloperError :需要点和时间。
-
DeveloperError : 点.长度必须大于或等于2。
-
DeveloperError : 时间长度必须等于点.长度.
Example:
// Create a natural cubic spline above the earth from Philadelphia to Los Angeles.
var 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:
f
i
将索引i放入times
中,使参数
time
在[times[i], times[i + 1]]
区间。Name | Type | Description |
---|---|---|
time |
Number | 时间。 |
Returns:
间隔开始时元素的索引。
Throws:
将给定时间包装为样条曲线覆盖的周期。
Name | Type | Description |
---|---|---|
time |
Number | 时间。 |
Returns:
时间,绕到更新的动画。