Skip to content

Commit

Permalink
Pull request 16 adapted
Browse files Browse the repository at this point in the history
  • Loading branch information
rveciana committed Jan 13, 2019
1 parent 121f9ff commit c3639a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- 5.2.0
- node
- v10.2.1
env:
- CXX=g++-4.8
before_script:
Expand Down
12 changes: 9 additions & 3 deletions build/path-properties.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// http://geoexamples.com/path-properties/ Version 0.4.6. Copyright 2018 Roger Veciana i Rovira.
// http://geoexamples.com/path-properties/ Version 0.4.7. Copyright 2019 Roger Veciana i Rovira.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
Expand Down Expand Up @@ -147,11 +147,12 @@
var t = length/total_length;
var step = (length - func(xs, ys, t))/total_length;

var numIterations = 0;
while (error > 0.001){
var increasedTLength = func(xs, ys, t + step);
var decreasedTLength = func(xs, ys, t - step);
var increasedTError = Math.abs(length - increasedTLength)/total_length;
var decreasedTError = Math.abs(length - decreasedTLength)/total_length;
var increasedTError = Math.abs(length - increasedTLength) / total_length;
var decreasedTError = Math.abs(length - decreasedTLength) / total_length;
if (increasedTError < error) {
error = increasedTError;
t += step;
Expand All @@ -161,6 +162,11 @@
} else {
step /= 2;
}

numIterations++;
if(numIterations > 500){
break;
}
}

return t;
Expand Down
Loading

0 comments on commit c3639a4

Please sign in to comment.