GithubHelp home page GithubHelp logo

Join bug about clipper2 HOT 5 CLOSED

angusjohnson avatar angusjohnson commented on July 20, 2024
Join bug

from clipper2.

Comments (5)

AngusJohnson avatar AngusJohnson commented on July 20, 2024

Hi Fribur.
Something certainly seems odd but I'll need some data to sort out what's happening.
You'll find a link to my email address here.

Unrelated, I have a hunch line 853 should be _vertexList.Add(curr_v); and not _vertexList.Add(v0);

Yes, that's definitely a bug. Thanks!

from clipper2.

Fribur avatar Fribur commented on July 20, 2024

Attached the three integer polygons leading to the result in picture above (consecutive union of 1+2-->result1, then result1+3--result2). Interestingly this only occurs when I add them as PathD. Using Path64 leads to the expected result. Puzzling.

var jobClipper2 = new Clipper2Lib.ClipperD();
...
jobClipper2.Execute(ClipType.Union, FillRule.EvenOdd, result);

Outline_0.txt
Outline_1.txt
Outline_2.txt

from clipper2.

AngusJohnson avatar AngusJohnson commented on July 20, 2024

OK, problem found.

private static double DistanceSqr(Point64 pt1, Point64 pt2)
{
  return (double) (pt1.X - pt2.X) * (pt1.X - pt2.X) +
         (double) (pt1.Y - pt2.Y) * (pt1.Y - pt2.Y);
}

The C# compiler indicated that my explicit casting to double in Clipper.Engine.DistanceSqr() was unnecessary (by fading out these casts). Unfortunately I removed them without testing the consequences and it turns out they are very much needed. Now I'm wondering what other casts I've removed that the compiler indicated were superfluous.

from clipper2.

rs0xFFFF avatar rs0xFFFF commented on July 20, 2024

I assume the math runs on integer (with rounding errors) and converts to float at last step (the result is wrong at that point).

from clipper2.

AngusJohnson avatar AngusJohnson commented on July 20, 2024

and converts to float at last step (the result is wrong at that point)

Yep. Anyhow, fixed now.

from clipper2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.