Easy way to get an "average" curvature of a given curve?

One way I guess would just be to sample the curve with Curve.CurvatureAt() at a given interval and collect/average the results… Is there a better/faster way via higher math (that I don’t know anything about)?

Thanks,
–Mitch

I need to verify the math but I believe for a planar curve without any reverse curvature the “average curvature” would be the difference in direction of the curve at either end expressed in radians divided by the length of the curve.

For a planar curve with reverse curvature the average of the curvature magnitude can be calculated by dividing the curve at inflection points and summing the magnitude of the differences in direction.

Non- planar curves are more complicated.

Not sure that’s it - at least not what I’m after. In the attached, two curves the same length and the same start/end tangents. However, they have completely different average curvatures - as they are both composed entirely of same radius arcs, the average is the same as the radius.

Perhaps I should be speaking here of average radius rather than curvature, not sure it it really means the same thing.

AvgCurvature.3dm (48.2 KB)

–Mitch

Radius = 1/Curvature and Curvature = 1/Radius

Sounds like you want the average of the absolute value or magnitude of the curvature. Since the direction of the curvature switches you need to break the curve at the inflection points.

The blue curve has two segments, each has a change of direction of Pi or 3.1416 radians for a total direction change of 6.2832
Average of the absolute value of curvature = 6.2832/62.832 = 0.1
Curvature of 0.1 corresponds to radius of 10.

The red curve has twenty segments, each has a change of direction of Pi or 3.1416 radians for a total direction change of 62.832
Average of the absolute value of curvature = 62.832/62.832 = 1.0
Curvature of 0.1 corresponds to radius of 1.0.

Note that unless the the curvature is constant, the average of the curvature usually does not equal the average of the radius.

In general the average of 1/x does not equal 1/(average of x).

David, in order to use your method you would need to know more than just start and end directions. You would also nee to know how many times the curve winds around. A line of length equal to the circumference of a circle would certainly have a different average curvature then the circle. Similarly for a spiral.

As you said, though, I think Mitch is looking for the average absolute value of curvature. To find that, I think you would have to break up at inflections and G2 breaks, then integrate the curvature and divide by length. You could approximate it fairly well using Reimann sums. Break the segment up into tiny intervals. Add all (segment midpoint curvature X segment length), then divide the total by the total length. Or something like that.

Chuck, you are correct that if the curve winds around, a spiral for instance with more than one turn you need to add in 2*Pi (6.2832) radians for each turn in addition to the beginning and end directions. A straight line has zero change in direction so the average curvature is zero.

As I previously said the curve needs to split at inflection points for the change in direction calculations. No need to break it up at G2 discontinuities or even G1 discontinuities (I’ll post examples in a few minutes).[quote=“chuck, post:5, topic:32648”]
You could approximate it fairly well using Reimann sums. Break the segment up into tiny intervals. Add all (segment midpoint curvature X segment length), then divide the total by the total length. Or something like that.
[/quote]That is a good method as long as the curvature doesn’t change too much in the length of the segments. If there are sections of the curve where there is high curvature for a short length then an integral approach may be better.

Break the curve into short segments. For each segment obtain the absolute value of the change in direction over that segment, and multiply it by the length of the segment. Sum all the segments and divide by the total length of the curve squared. (This paragraph has been corrected.)

Yeah, when I said break at G2 breaks, I was thinking about actually doing the integration. Even there it probably isn’t necessary.

Example extended with two more curves which are almost but not quite identical, average curvature on both is 0.1.

The dark green curve has straight segments connected with fillets.The straight segments have zero curvature, and the fillets have radius of 0.1, curvature of 10. Average curvature is 0.1 and can be calculate both by the intergration of the curvature along the curve and by the direction change method.

The bright green curve has straight segments and sharp corners. The straight segments have zero curvature. The sharp corners have zero radius and infinite curvature but zero length. The direction change method results in average curvature or 10.

AvgCurvatureDC1.3dm (67.0 KB)

Yes, that’s correct, I didn’t really know how to state this. Let me give you a quick background on why I am looking at this -

We have lasers here that run on HPGL, and we feed them all sorts of curves - lines, polylines, arcs/circles and lots of junky topo line curves which could be either splines or dense polylines. I have a scripted cutting time estimator I wrote, and it’s reasonably close, with one notable exception: on tight radius curves, the laser slows down significantly, because the driver seems to be breaking it up into a whole series of small segments to keep the curve smooth and within tolerance. My estimator, which mainly just uses curve length to estimate time, cannot detect these situations.

An example:
I have two files, one has 1000 2mm diameter circles, the other has 1000 2mm squares. The circles take almost 40% longer to cut, despite the fact that the total cutting length is only 79% as long as the squares. Hence the tight radius circles cut at almost 50% slower speed. We notice this slowdown on splines that have a lot of sharp wiggles as well.

So, as an intellectual exercise, I wanted to try to detect a certain threshold level of “curve sharpness” and put in a compensation curve in my estimator… But this is not really anything important or critical, I’m just playing around with it is all. Thanks for the responses!

–Mitch

Hi Mitch, [quote=“Helvetosaur, post:9, topic:32648”]
the driver seems to be breaking it up into a whole series of small segments to keep the curve smooth and within tolerance
[/quote]
you could try to simulate the behavior of the driver and _Convert the cutting paths to polylines. Then calculate something like this: PathLength / CuttingSpeed + PointCount * delay

It should not be to hard to estimate the delay.

Hmm, yeah, that sounds like an interesting approach, thanks Jess! As soon as I get out of “charrette mode” here, I’ll have a hack at it.

Cheers, --Mitch

Yeah, cheers :wink: