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

intersects bug Bezier to Bezier #201

Open
RGBWang opened this issue Jul 13, 2023 · 3 comments
Open

intersects bug Bezier to Bezier #201

RGBWang opened this issue Jul 13, 2023 · 3 comments

Comments

@RGBWang
Copy link

RGBWang commented Jul 13, 2023

new Bezier(50, 25, 50, 25, 122, 185, 111, 185);
var curve2 = new Bezier(9, 111, 8, 99, 136,78, 142, 58 );
var draw = function() {
  this.drawSkeleton(curve);
  this.drawCurve(curve);
  this.setColor("red");
  this.drawCurve(curve2);
  this.setColor("black");
  curve.intersects(curve2).forEach(pair => {
    var t = pair.split("/").map(v => parseFloat(v));
    this.drawPoint(curve.get(t[0]));
  });
}
@Pomax
Copy link
Owner

Pomax commented Jul 16, 2023

Don't just text-dump: please explain what's wrong, and how this code shows that off.

@RGBWang
Copy link
Author

RGBWang commented Aug 1, 2023

when copy the code in /docs/index.html ,

<script type="text/beziercode"> ,you can see the bug .two clearly intersecting lines, but not detected

Snipaste_2023-08-01_10-00-46

@Pomax
Copy link
Owner

Pomax commented Aug 1, 2023

It looks like you've turned the black curve into a degenerate curve by overlapping its control point with its start point, which will indeed cause problems. The current solution is to make sure to work with "real" curves rather than degenerate ones, which in this case is simply moving the control point in the direction of the second control point by a small amount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants