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
Curve.evaluate() should handle straight curves separately #838
Comments
I completely agree, this is far from ideal. I'll have to do a proper analysis of this soon! |
I closed this issue too early, since my fix addresses the problem of tiny handles after boolean operations, but now how |
Looks like my merging mess closed this one again... |
Here a simple sketch illustrating the issue. |
Hmmm... Since this handle is pointing to the left, do you think it's actually right that this is considered a straight curve? I'm not quite sure yet what's the right way to deal with this issue... |
Let me know if this works for you @iconexperience |
Yep, that seems to work. It's consistent with |
While working on path offsetting I ran into a very strange behaviour of straight curves in some cases.
Here is a simple boolean example that creates a path consisting of straight curves:
This is how it looks:
As you can see in this sketch,
isStraight()
returnstrue
for all curves in the path (which means the curves are lines), so everything looks alright.But the full truth is that two curves in the path actually have tiny handles.
isStraight()
sees them within tolerance, which is the correct behaviour. Here are the values for the last curve:[ 50, 150, 49.99999999999999, 150, 100.00000000000001, 150.00000000000003, 100.00000000000001, 150.00000000000003 ]
As you can see from the values, there is a tiny handle at the left with length 1e-14. This handle is pointing to the left, while to whole curve (or line) runs from left to right.
The strange thing happens if you call
getNormalAt()
for the start and the end point of the curve. SinceisStraight()
returns true, one would expect thatgetNormalAt()
returns the same value for all parameters on the curve, but this is not what happens. InsteatgetNormalAt(0, true)
returns{x:0, y:1}
andgetNormalAt(1, true)
returns{x:0, y:-1}
. Here is the sketch.The reason for this behaviour is that
getNormalAt
(orevaluate()
) does not distinguish between straight and non-straight curves and always uses the direction of the handle at the end point for the tangent, if a handle exists. Since we have tiny handle at the start point which is pointing to the opposite direction of the curve, the normal suddenly becomes inverted.For path offsetting this is a real problem, because the offset curve of a straight line changes side, while we would expect it to simply be a parallel line.
While we are at this we should also look why the curves grow tiny handles in the boolean operation. Maybe this is unavoidable, but of course it would be better if a line stays a line in boolean operations.
The text was updated successfully, but these errors were encountered: