Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jeremie Garcia
Trajectoires
Commits
93cd3c6b
Commit
93cd3c6b
authored
Mar 02, 2016
by
Jack Woodward
Browse files
Added simplify function.
Added the basic version of the simplify algorithm.
parent
486193a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Traj/server/interfaces/js/timedCurve.js
View file @
93cd3c6b
...
...
@@ -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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment