Commit 93cd3c6b authored by Jack Woodward's avatar Jack Woodward
Browse files

Added simplify function.

Added the basic version of the simplify algorithm.
parent 486193a6
......@@ -241,6 +241,42 @@ TimedCurve.prototype.getClosestPointIndex = function(pos) {
TimedCurve.prototype.simplifySmart = function(tolerance){
//todo
return this;
var points = [];
var pt = {};
//declare variable
var curve = this;
var result = new TimedCurve(curve.sourceNumber);
//add first point and set it as the last added point/
result.addTimedPoint(curve.X[0],curve.Y[0],curve.Z[0],curve.t[0]);
points.push(pt);
var lastPoint = 0;
for(var i = 1; i < curve.X.length; i++){
//adds point every 2 points no matter what/
if(i - lastPoint >= 2){
result.addTimedPoint(curve.X[i],curve.Y[i],curve.Z[i],curve.t[i]);
lastPoint = i;
}
//checks time difference betwen each point;
//if difference is substancial, is included in curve/
var currentTime = curve.t[i];
var lastTime = curve.t[i-1];
if(currentTime - lastTime > 100){
result.addTimedPoint(curve.X[i],curve.Y[i],curve.Z[i],curve.t[i]);
}
}
//returns simplified curve
return result;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment