0
votes

I'm currently working on a program that takes a scale SVG file of a race track and uses the data to approximate the track as an array of points. Ideally, the absolute value of the slopes between any two consecutive points would be identical, as this would allow me to approximate the angle, arc length and radius to a known accuracy for use in calculating the maximum velocity around the curve.

The SVG uses a Bezier approximation with 2 control points. I have a function that takes a start point, 2 control points and an end point as well as the parametric variable t. I found the code for this here: Drawing Bezier curves using De Casteljau Algorithm in C++ , OpenGL

The result I'd like is that straights would consist of very few line segments (slope changes very little), while sharp turns would consist of many line segments (slope changes sharply). This would keep a constant accuracy in the calculations.

Using a constant step for t doesn't provide a constant slope between two points, which is a huge issue for the calculations. Is there any way to find the correct t value knowing the desired slope of the resulting line segment?

1
The maximum curvature will occur at one of the endpoints. If you find the maximum curvature, then you should be able to determine a step size that will guarantee your slope doesn't change too much between consecutive line segments.Vaughn Cato
@squeamishossifrage: Sorry, I should have said the second derivatives, not the curvature. The geometric curvature can be at a maximum anywhere. The (absolute value of) the second derivatives of x and y w.r.t t will be at a maximum at one of end points though, so you should be able to determine an upper bound on the acceleration. It seems like this might be useful, since when the curve has a high geometric curvature near the middle, it is actually slowing down w.r.t t, so the line segments would automatically become shorter. But I can see this isn't perfect.Vaughn Cato
Is your final goal to calculate the t value where the maximum velocity occurs?Vaughn Cato
This feels like an XY Problem formulation. What do you want to do, that you think you need this for? Because you're not "working on a program that takes a scale SVG file of a race track and uses the data to approximate the track as an array of points", I'm pretty sure ultimately you want to do something with those points: what do you want to do with them? Do you want to form equidistance segments? Constant speed curve traversal with race car, etc. etc?Mike 'Pomax' Kamermans

1 Answers

1
votes

After much searching and refining of terms, I've found a site that explains in depth the answer to my problem. Turns out that my problem is the same faced by rendering engines for drawing Bezier curves, and the Anti-Grain Rendering Engine has a wonderful tutorial on subdividing Bezier curves to approximate all kinds of twists and turns.

https://web.archive.org/web/20180307160123/http://antigrain.com/research/adaptive_bezier/index.html