Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion in VertexReduction #87

Open
lamdalili opened this issue Jun 6, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@lamdalili
Copy link

commented Jun 6, 2019

If VertexReduction called with closed path an infinite recursion will result in RamerDouglasPeucker
I am not sure to understand the code but when I replace > with >= seems work
code in RamerDouglasPeucker

    for Index := FirstIndex + 1 to LastIndex - 1 do
    begin
      with Points[LastIndex] do
        Delta := Abs((Points[Index].x - x) * (Points[FirstIndex].y - y) -
          (Points[Index].y - y) * (Points[FirstIndex].x - x));
      if Delta >= DeltaMax then  // instead of '>'
      begin
        DeltaMaxIndex := Index;
        DeltaMax := Delta;
      end;
    end;

@andersmelander andersmelander added the bug label Jun 6, 2019

@andersmelander

This comment has been minimized.

Copy link
Member

commented Jun 15, 2019

The implementation of the Ramer-Douglas-Peucker algorithm appears to be correct although it is a bit strange that the float and fixed implementations uses different methods of calculating the point to line distance (and both seem to do it wrong: distance to line <= distance to line segment).

I don't have time to create a reproducible test case and I have not been able to spot the cause of any infinite recursions by looking at the code or running it in my head, so I'm afraid I'll have to defer this to @CWBudde who is the one that implemented this.

@CWBudde

This comment has been minimized.

Copy link
Contributor

commented Jun 23, 2019

I can confirm the issue, but at the moment I don't have time for this. I'll put it on my todo list for after the summer holiday.
Note for my future self: See https://de.wikipedia.org/wiki/Douglas-Peucker-Algorithmus and in particular https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.