-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
optimize utils.droots #218
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update your description to explain why you filed this and what you think the new code does that the old code doesn't.
PRs are absolutely welcome, but I need to know why you're suggesting these changes, because looking at what you changed this is almost certainly motivated by fixing a bug related to taking the square root of a negative number, so you'll have to include (or at the very least talk about) a test case where the current code fails, and this new code doesn't.
Hello, this is a small optimization. I found that Sometimes, result[dim] = result[dim].filter(function(t2) {
return t2 >= 0 && t2 <= 1;
}); So I think we can optimize it. When the square of the "delta of the quadratic formula" is negative, it means that the quadratic equation has no real roots, and sqrt will return NaN when the input is a negative number. It's a good idea to return
|
Cheers. Do you have an example curve/code snippet we can add to the tests for this? |
Well, this is not a bug. I just made a small change to new Bezier(
[
{
x: 100,
y: 206,
},
{
x: 121,
y: 47,
},
{
x: 141,
y: 273,
},
{
x: 215,
y: 348,
},
]
).extrema() The example above will get an array with NaN in the X dimension in the |
No description provided.