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

Floating point rounding error causes bug in Bezier.simple() #187

Open
stoarca opened this issue Dec 30, 2022 · 2 comments
Open

Floating point rounding error causes bug in Bezier.simple() #187

stoarca opened this issue Dec 30, 2022 · 2 comments

Comments

@stoarca
Copy link

stoarca commented Dec 30, 2022

Here's a test case:

let bezier = new Bezier(
  {
    "x": 14.187262535095215,
    "y": 8.270401954650879
  },
  {
    "x": 14.179354667663574,
    "y": 8.262494087219238
  },
  {
    "x": 14.179354667663574,
    "y": 8.262494087219238
  },
  {
    "x": 14.171446800231934,
    "y": 8.254586219787598
  }
);
let ret = bezier.reduce();
console.log(ret);

I expect ret to be non-empty. The bug is in Bezier.simple():

image

This can be fixed by clamping s between -1 and 1.

@Pomax
Copy link
Owner

Pomax commented Jan 1, 2023

That's not a rounding error. That's literally how IEEE floats work, but clamping is still a good idea.

@stoarca
Copy link
Author

stoarca commented Jan 1, 2023

by "rounding error" i was referring to the possible delta between the IEEE result and the exact mathematical result https://en.wikipedia.org/wiki/Round-off_error

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

No branches or pull requests

2 participants