![](https://secure.gravatar.com/avatar/164f86a2bf37758e8c5aabb2e79bfdac.jpg?s=120&d=mm&r=g)
So, this is a callout to anyone who is familiar with the mathematics of beziers, I need your help, generally, but also specifically. Generally, if you would be willing to volunteer as someone I can consult with on bezier math, that would be great, give me a shout. Specifically, I want to write a method that outputs a list of equally spaced points along a bezier BUT, I don't mean equally spaced t-values for the bezier -- I can already do this -- I mean points that are of equal distance along the bezier. I'm almost certain the two are distinct. Any suggestions ? A lot of potential functionality for path effects seem to rest on this ability.
![](https://secure.gravatar.com/avatar/01c2dd03530db1afb305df3aaad0fed8.jpg?s=120&d=mm&r=g)
Justin Wikinator wrote:
So, this is a callout to anyone who is familiar with the mathematics of beziers, I need your help, generally, but also specifically. Generally, if you would be willing to volunteer as someone I can consult with on bezier math, that would be great, give me a shout. Specifically, I want to write a method that outputs a list of equally spaced points along a bezier BUT, I don't mean equally spaced t-values for the bezier -- I can already do this -- I mean points that are of equal distance along the bezier. I'm almost certain the two are distinct. Any suggestions ? A lot of potential functionality for path effects seem to rest on this ability.
The "Add Nodes" effect does this for individual bezier segments.
Aaron Spike
![](https://secure.gravatar.com/avatar/61ce0f8abd1c597e4644d406b802f097.jpg?s=120&d=mm&r=g)
On 5/26/06, Justin Wikinator <touchmewithsynchronicpulses@...400...> wrote:
Specifically, I want to write a method that outputs a list of equally spaced points along a bezier BUT, I don't mean equally spaced t-values for the bezier -- I can already do this -- I mean points that are of equal distance along the bezier. I'm almost certain the two are distinct. Any suggestions ?
Yes, the two are distinct. The concept you are interested in is called arc-length, and has a calculus definition:
Integral( sqrt( dx/dt ^ 2 + dy/dt ^ 2 ), t )
Here, dx/dt and dy/dt are the derivatives of the Bezier x(t) and y(t) functions. The trouble is, by the time you square them and add them together, you have a quartic equation. Integrating the square root of a quartic equation is insanely hard. I expect the solution would take a few pages of paper just to print out, if it's even possible to get a symbolic solution in the first place.
In practice, the best you can get is an approximation. Just divide the curve into several tiny line segments and sum their lengths. From there, some sort of binary-search algorithm could find the midpoint. It could be pretty straightforward to get working, but might take some serious tweaking to make it both accurate and fast.
Feel free to email me if you have any more Bezier math questions, or even just more help with the arc-length stuff.
-William Swanson
![](https://secure.gravatar.com/avatar/dc940f48c5635785f32941f1fbe6b601.jpg?s=120&d=mm&r=g)
On May 26, 2006, at 12:05 PM, Justin Wikinator wrote:
Specifically, I want to write a method that outputs a list of equally spaced points along a bezier BUT, I don't mean
[SNIP]
I'm almost certain the two are distinct. Any suggestions ? A lot of potential functionality for path effects seem to rest on this ability.
If this is for Inkscape code itself, you might want to look into the routine being used for the "startOffset" of text on a path. There are some aspects of it that seem less than "mathematically pure" to me, but pragmatically are more appropriate for certain solutions. (I think this even counts dealing paths made of disjoint segments)
Anyway, I'm aware of the code involved having been used for something else, but before I could look into details to be able to add startOffset to text-on-path, Bulia told me to look as he'd snuck in and implemented things already.
participants (4)
-
Aaron Spike
-
Jon A. Cruz
-
Justin Wikinator
-
William Swanson