Search code examples
svgcurvebezier

Biciycle wheel path and bezier curves


I am trying to draw the path of a bicycle front wheel while only the bezier curve of the rear wheel is known. Now, I think I know how to get the formula, but the answer must be a (set of) Bezier curve(s). I'm guessing that, if the rear wheel path is a Bezier curve, the front wheel path is not neccessary one. So probably I will have to recurively approximate it using more than one curve ?

I want to view the result in SVG.

Please try to explain in small steps since my math is a bit rusty after 26years...

To get an idea of what I'm talking about, look at: Bicycle wheel path example

Some background information may be helpful here: I'm trying to build a plugin for Inkscape that calculates the path that a CNC machine should follow when moving a swivel knife with a given offset. This is similar to having a known bicycle rear wheel path and trying to derive its front wheel path from that. So, the input is an SVG file with paths in it (the shapes I want to cut) and the output is the same file with extra SVG paths added to it (the paths the CNC machine should follow in order to cut the desired shapes with a swivel-knife).

The funny thing is that the bicycle will start it's ride driving along the line that is exactly parallel to the line between the starting point and its control point and will end its ride exactly parallel to the line between the end point of the Bezier curve and its control point. It's what's happening between these points that seems to be out of my control...


Solution

  • GOT IT !

    I think I found an elegant solution to this problem after carefully reviewing the primer that KIKO showed me. Look at paragraph 6 (De Casteljau algorithm)

    Note that the green line is tangent to the Bezier curve. We can use it to represent the frame (with length L) of the bicycle (which is always parallel to this line). This makes it very easy to draw the front wheel path.

    But I need the front wheel path in the form of Bezier curves…

    Step1: Duplicate the first Bezier curve and modify it so that the first 2 control points (p1 and p2 in the example) are offset with length L parallel to line(p1,p2). Do the same thing with P3 and P4. This Bezier will be our first estimation of the front wheel path. Step2: Start drawing the Bezier curves for the rear and the front wheel simultaneously keeping track of the difference between the calculated front wheel path and the estimated front wheel Bezier curve. If the difference becomes to big, split the estimated Bezier curve and adjust the new-formed control-point. Repeat this process until drawing is finished.