Giter Club home page Giter Club logo

Comments (12)

aab29 avatar aab29 commented on July 19, 2024

Hey @fidlip ! Thanks a ton for pointing this out! ๐Ÿ˜ฎ๐Ÿ‘ I got a chance to copy/paste and walk through your code snippet myself, and so far I'm thinking you've found a legit bug. ๐Ÿž

I did notice that one of the 52.0 values seems to be subtracted in bezier2, whereas it was added in bezier1... but I've tried it both ways, and it doesn't seem to make a difference. I think it should still be finding an intersection for bezier1, and it's not. ๐Ÿ™ˆ

I probably won't have time today to get to the cause of this, but I wanted to thank you and let you know that @IkeBart and I will be looking into it. ๐Ÿ•ต It seems like the value output by rootsAlongLine is producing a point that is just outside the bounding box of the line segment. I'm not sure exactly why this might happen. Possibly an issue with floating point precision? ๐Ÿฆˆ We'll also have to check with Bezier.js to see if @Pomax 's library has the same issue, or if we introduced it. โžฐ I have a feeling it was something I messed up. ๐Ÿ˜…

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

Thank a lot for reply. When I tried to debug through library code, I had similar observation... but was not able to prepare some fix to offer you some PR.

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

I hit another situation:

  CubicBezier bezier3 = CubicBezier([Vector2(214.5,630), Vector2(308.25,630), Vector2(368.625,492.5), Vector2(429,355)]);
  List<double> intersections3 = bezier3.intersectionsWithLineSegment(Vector2(0,580), Vector2(430,580));
  print("bezier3 intersections= $intersections3");

  // translate 6px up
  CubicBezier bezier4 = CubicBezier([Vector2(214.5,630 - 6.0), Vector2(308.25,630 - 6.0), Vector2(368.625,492.5 - 6.0), Vector2(429,355 - 6.0)]);
  List<double> intersections4 = bezier4.intersectionsWithLineSegment(Vector2(0,580 - 6.0), Vector2(430,580 - 6.0));
  print("bezier4 intersections= $intersections4");

  // translate 6px down
  CubicBezier bezier5 = CubicBezier([Vector2(214.5,630 + 6.0), Vector2(308.25,630 + 6.0), Vector2(368.625,492.5 + 6.0), Vector2(429,355 + 6.0)]);
  List<double> intersections5 = bezier5.intersectionsWithLineSegment(Vector2(0,580 + 6.0), Vector2(430,580 + 6.0));
  print("bezier5 intersections= $intersections5");

will print out:

bezier3 intersections= []
bezier4 intersections= [0.37197975112055826]
bezier5 intersections= [0.37197975112055826]

in case of bezier3 it should be the same intersection as in following cases bezier4 & bezier5

from bezier.dart.

aab29 avatar aab29 commented on July 19, 2024

Thanks again! These will make great test cases when we get a chance to sit down and find a fix. ๐Ÿ”งโœ…

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

Hi Aaron, is there anything I could help you with to solve this issue?

from bezier.dart.

aab29 avatar aab29 commented on July 19, 2024

Hey @fidlip ! Sorry for the delay. โณ It was a busy week, and now I'm on a vacation with less down time than anticipated. ๐Ÿ– I'll try to take a look at this myself tonight, and if not I'll look at it on the plane tomorrow. โœˆ๏ธ It's possible I'll need @IkeBart 's help, and if that's the case we can look at it on Monday or Tuesday. I'm pretty sure we can track it down ourselves, but PRs are always welcome, and if we're stumped on something, we'll definitely share the issue. ๐Ÿค“ ๐Ÿค“ ๐Ÿ‘ Thanks! ๐Ÿ˜Ž

from bezier.dart.

aab29 avatar aab29 commented on July 19, 2024

I think I might know what's going on. ๐ŸŒต Like we were saying before, it seems like the points produced by plugging the roots back into the curve are just outside the bounding box of the line segment. ๐Ÿ”Œ ๐Ÿ™…โ€โ™‚ They're outside by such a small amount, it could easily be introduced by floating point imprecision. ๐Ÿ“Œ

However, I checked the algorithm against its counterpart in Bezier.js, and I noticed one thing they're doing that is subtly different, but apparently important. โš ๏ธ When they check to see whether points fall within the bounding box, they're relying on the between function. ๐Ÿ˜ฎ And of course, between relies on approximately, which checks for approximate equality--something we're not doing. ๐Ÿคฆโ€โ™‚ I'm pretty sure once I add in just a little bit of fuzziness, the failing test cases will pass. ๐Ÿป It seems my suspicions were correct--this was something I messed up. ๐Ÿ˜œ Thanks for helping me find it! ๐Ÿ”

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

from bezier.dart.

aab29 avatar aab29 commented on July 19, 2024

No problem! I'm glad we were able to track it down. ๐Ÿ•ต ๐Ÿ†’ Please check out the PR I already merged and the new release I made on Pub and make sure everything is in order. ๐Ÿ†• If it is, I think we can close this issue. ๐Ÿ‘ Cheers! ๐Ÿป

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

Hi Aaron. Thanks a lot. I will check it out in two days and let you know.

from bezier.dart.

fidlip avatar fidlip commented on July 19, 2024

Hi, I tested it finally. It seems to be working. Good job! Thank you again!

from bezier.dart.

aab29 avatar aab29 commented on July 19, 2024

Awesome! ๐Ÿ˜Ž You're very welcome. Thanks for alerting us to the bug! ๐Ÿž ๐Ÿ”จ

from bezier.dart.

Related Issues (8)

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.