Closed SimonbJohnson closed 2 years ago
This is accurate (though not for circular arcs) bezier curves operate like that. Different slices of T even linear slices of T are not linear. In fact, the speed of the curve changes. The value submitted by .point()
is t
as that's how the curves are converted. I don't know how you could properly calculate purely evenly spaced segments except with a recursive brute force algorithm.
You could possibly use bresenham-zingl algorithms to draw the curves with for a suitably small distance and raster the curve into discrete points and sample it each n-pixels or so. But, this mostly is to do with the nature of Bezier curves. You can find the position of t
but not necessarily the curve that is exactly d
distance long for each subdivision.
https://pomax.github.io/bezierinfo/#tracing
If something along that line is required. Should be pretty solid explanation of the problem, and a summary of the various solutions.
Hi, this makes complete sense! I will use the above linked technique to search for linear increments to a certain tolerance. Thank you. Happy to share my implementation here when done for others. Would this be something you would be interested in being implemented in the library?
Perhaps if the code was very short and worked in numpy too. It's a bit outside the regular bounds of the project. And it would seem like the same would be needed for non-circular arcs to provide such functionality across the board. It's not out of the question but the answer is probably no. But, if it's like three really pretty lines I could see an implementation being reasonable.
I'm unlikely to make something that concise, so i will close for now and share a code snippet here when I implement for reference. Thanks
I'm using the .point() function to return points along a curve, but these are not linear as expected. Below is sample code and sample SVG that replicates the problem. The SVG contains a straight line represented by a curve created by Inkscape. In the table below we can see the change in x starts as ~49 and by the end the change is ~0.25 for the same fraction move along the line. If the same function is parsed along a line the results are as expected.
Code:
SVG: