mt-polygon-simplification/lib/simplify-js-alternative/simplify.diff

43 lines
1.0 KiB
Diff
Raw Normal View History

2019-07-14 20:37:26 +02:00
1,9d0
< /*
< (c) 2013, Vladimir Agafonkin
< Simplify.js, a high-performance JS polyline simplification library
< mourner.github.io/simplify-js
< */
<
< // to suit your point format, run search/replace for '.x' and '.y';
< // for 3D version, see 3d branch (configurability would draw significant performance overhead)
<
13,14c4,5
< var dx = p1.x - p2.x,
< dy = p1.y - p2.y;
---
> var dx = p1[0] - p2[0],
> dy = p1[1] - p2[1];
22,25c13,16
< var x = p1.x,
< y = p1.y,
< dx = p2.x - x,
< dy = p2.y - y;
---
> var x = p1[0],
> y = p1[1],
> dx = p2[0] - x,
> dy = p2[1] - y;
29c20
< var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy);
---
> var t = ((p[0] - x) * dx + (p[1] - y) * dy) / (dx * dx + dy * dy);
32,33c23,24
< x = p2.x;
< y = p2.y;
---
> x = p2[0];
> y = p2[1];
41,42c32,33
< dx = p.x - x;
< dy = p.y - y;
---
> dx = p[0] - x;
> dy = p[1] - y;