Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing quadrilateral interpolation #5740

Merged
merged 7 commits into from
Jan 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ Change Log
* Only one node is supported.
* Only one mesh per node is supported.
* Only one primitive per mesh is supported.
* Fixed a glTF animation bug that caused certain animations to jitter. [#5740](https://github.com/AnalyticalGraphicsInc/cesium/pull/5740)
* Updated documentation links to reflect new locations on cesiumjs.org and cesium.com.

### 1.41 - 2018-01-02
63 changes: 3 additions & 60 deletions Source/Core/QuaternionSpline.js
Original file line number Diff line number Diff line change
@@ -14,43 +14,11 @@ define([
Spline) {
'use strict';

function computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle) {
var length = points.length;
var quads = new Array(length);

quads[0] = defined(firstInnerQuadrangle) ? firstInnerQuadrangle : points[0];
quads[length - 1] = defined(lastInnerQuadrangle) ? lastInnerQuadrangle : points[length - 1];

for (var i = 1; i < length - 1; ++i) {
quads[i] = Quaternion.computeInnerQuadrangle(points[i - 1], points[i], points[i + 1], new Quaternion());
}

return quads;
}

function createEvaluateFunction(spline) {
var points = spline.points;
var quads = spline.innerQuadrangles;
var times = spline.times;

// use slerp interpolation for 2 points
if (points.length < 3) {
var t0 = times[0];
var invSpan = 1.0 / (times[1] - t0);

var q0 = points[0];
var q1 = points[1];

return function(time, result) {
if (!defined(result)){
result = new Quaternion();
}
var u = (time - t0) * invSpan;
return Quaternion.fastSlerp(q0, q1, u, result);
};
}

// use quad interpolation for more than 3 points
// use slerp interpolation
return function(time, result) {
if (!defined(result)){
result = new Quaternion();
@@ -60,15 +28,13 @@ define([

var q0 = points[i];
var q1 = points[i + 1];
var s0 = quads[i];
var s1 = quads[i + 1];

return Quaternion.fastSquad(q0, q1, s0, s1, u, result);
return Quaternion.fastSlerp(q0, q1, u, result);
};
}

/**
* A spline that uses spherical quadrangle (squad) interpolation to create a quaternion curve.
* A spline that uses spherical linear (slerp) interpolation to create a quaternion curve.
* The generated curve is in the class C<sup>1</sup>.
*
* @alias QuaternionSpline
@@ -78,10 +44,6 @@ define([
* @param {Number[]} options.times An array of strictly increasing, unit-less, floating-point times at each point.
* The values are in no way connected to the clock time. They are the parameterization for the curve.
* @param {Quaternion[]} options.points The array of {@link Quaternion} control points.
* @param {Quaternion} [options.firstInnerQuadrangle] The inner quadrangle of the curve at the first control point.
* If the inner quadrangle is not given, it will be estimated.
* @param {Quaternion} [options.lastInnerQuadrangle] The inner quadrangle of the curve at the last control point.
* If the inner quadrangle is not given, it will be estimated.
*
* @exception {DeveloperError} points.length must be greater than or equal to 2.
* @exception {DeveloperError} times.length must be equal to points.length.
@@ -96,8 +58,6 @@ define([

var points = options.points;
var times = options.times;
var firstInnerQuadrangle = options.firstInnerQuadrangle;
var lastInnerQuadrangle = options.lastInnerQuadrangle;

//>>includeStart('debug', pragmas.debug);
if (!defined(points) || !defined(times)) {
@@ -111,11 +71,8 @@ define([
}
//>>includeEnd('debug');

var innerQuadrangles = computeInnerQuadrangles(points, firstInnerQuadrangle, lastInnerQuadrangle);

this._times = times;
this._points = points;
this._innerQuadrangles = innerQuadrangles;

this._evaluateFunction = createEvaluateFunction(this);
this._lastTimeIndex = 0;
@@ -148,20 +105,6 @@ define([
get : function() {
return this._points;
}
},

/**
* An array of {@link Quaternion} inner quadrangles for the control points.
*
* @memberof QuaternionSpline.prototype
*
* @type {Quaternion[]}
* @readonly
*/
innerQuadrangles : {
get : function() {
return this._innerQuadrangles;
}
}
});

3 changes: 1 addition & 2 deletions Specs/Core/QuaternionSplineSpec.js
Original file line number Diff line number Diff line change
@@ -79,9 +79,8 @@ defineSuite([
var time = (times[2] + times[1]) * 0.5;
var t = (time - times[1]) / (times[2] - times[1]);

var quads = qs.innerQuadrangles;
var actual = qs.evaluate(time);
var expected = Quaternion.squad(points[1], points[2], quads[1], quads[2], t, new Quaternion());
var expected = Quaternion.slerp(points[1], points[2], t, new Quaternion());
expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON6);
});