richsmith / sexytopo

The SexyTopo cave surveying app for Android
GNU General Public License v3.0
30 stars 13 forks source link

Simplify sketch paths using Douglas-Peuker algorithm #150

Closed danielworkman closed 3 years ago

danielworkman commented 3 years ago
danielworkman commented 3 years ago

If you look at the implementation of the algorithm you can see that that will not be the case. You could run the algo 1000 times on a geometry simplified just once and nothing would happen

On Thu, 10 Jun 2021 at 08:36, Rich Smith @.***> wrote:

@.**** commented on this pull request.

In app/src/main/java/org/hwyl/sexytopo/control/io/basic/SketchJsonTranslater.java https://github.com/richsmith/sexytopo/pull/150#discussion_r648927227:

@@ -161,6 +160,11 @@ public static PathDetail toPathDetail(JSONObject json) throws JSONException { }

     PathDetail pathDetail = new PathDetail(path, colour);

+

  • double epsilon = Space2DUtils.SketchEpsilon(pathDetail);
  • List simplifiedPath = Space2DUtils.Simplify(path, epsilon);
  • pathDetail.setPath(simplifiedPath);

You probably understood what I meant, but just checking: we don't just need the result to be the same for the same input, but we also need the result to be the same for feeding the output of the first pass back into the algorithm. That is, we don't want the paths to get progressively simpler every time the file gets loaded.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/richsmith/sexytopo/pull/150#discussion_r648927227, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGM4DA6BWCBTHVWJZQWI27DTSBTRHANCNFSM46MTJVHQ .

richsmith commented 3 years ago

If you look at the implementation of the algorithm you can see that that will not be the case. You could run the algo 1000 times on a geometry simplified just once and nothing would happen

I guess I should stop being lazy and understand what the algo does!

[...]

OK, think I understand it now. Quite elegant. Yep, should be fine.