1

I'm trying to calculate the minimum radius in a cubic Bezier curve (in C#). I know this question is around on StackExchange, and have thoroughly browsed the answers and tried different implementations. However, the results are not what I expect.

Given this Bezier curve:

Simple cubic Bezier curve

If the curvature for a Bezier is k(t), I would expect it be exactly 0.1 for any given value of t for this specific curve. Given my results, this seems incorrect: the minimum is 7.5. If I calculate the radius (given as 1 / k(t)) for 10.000 values between 0 and 1, and then take the mean of that, I do get 10 (with some rounding errors). Does this make sense?

My goal is to find the minimum radius of given Bezier curve, where the curve will always bend in one direction. Thus, if one were to roll a ball of varying size along the Bezier, and this ball would always exactly fit as precisely as possible to the curve, what is the smallest it will get?

Thank you for any thoughts.

mennowo
  • 113
  • Why do you expect the curvature to "be exactly 0.1 for any given value of t for this specific curve"? Only a circular arc has constant curvature. If you want to approximate a circular arc using a cubic Bézier curve, see https://math.stackexchange.com/q/873224/207316 – PM 2Ring Oct 27 '21 at 12:45
  • I'm actually looking for a way to calculate the radius of a cubic bezier curve that bends in one direction. In case of the example curve, I'd expect the calculated radius to be identical for each point on the curve. Is that assumption correct? – mennowo Oct 28 '21 at 06:48
  • No, that assumption is incorrect. You didn't say how you calculated the curvature, but yes, it has minimum radius of curvature of 7.5 at the endpoints. At t=0.5, the radius is ~11.9324269325230. The mean radius, found by numerically integrating from t=0 to t=1, is ~10.0487338309514. Here's a plot. These points: [(0, 0), (40/3*sqrt(2) - 40/3, 0), (10, -40/3*sqrt(2) + 70/3), (10, 10)] give a better approximation to a quarter circle, so the range of the radius is much smaller, as this plot shows. – PM 2Ring Oct 28 '21 at 07:29
  • The curvature c is calulated by first getting the first and second derivaties (d1 and d2) of the Bezier, and then doing: c = (d1.X^2 + d1.Y^2) / sqrt((d1.X * d2.Y - d2.X * d1.Y)^3). This indeed gives me the results you mention. Taking a closer look in Inkscape I now also see that my initial curve indeed does not coincide with a quarter of a cirlce. Thanks! – mennowo Oct 28 '21 at 08:14
  • That curvature equation is a bit mixed up, but I guess that's a typo. – PM 2Ring Oct 28 '21 at 08:31
  • Well, I might have wrongly copied it from somewhere, but the results of this equation match your values. Meanwhile, I found another much simpler way to achieve my goal: I have two straight lines before and after the bezier: now I rotate those lines by a 90 degree angle at the point where they are attached to the Bezier, then determine the point of intersection. Subsequently, I can simply get the distance between that point and any given point on the Bezier. This works, but only because of my very specific situation. Thanks for your help! – mennowo Oct 28 '21 at 10:54
  • Ok. The correct parametric curvature equation is here: https://math.stackexchange.com/q/275248/207316 and the radius of curvature is (of course) the reciprocal of the curvature. – PM 2Ring Oct 28 '21 at 11:14

0 Answers0