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 1 commit
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
61 changes: 2 additions & 59 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,10 +28,8 @@ 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);
};
}

@@ -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;
}
}
});