Bezier "bendiness"?

Hi,

I'm trying to come up with some closed form characterizations of cubic beziers.

Currently, I'm exploring algorithms to quantify the "bendi-ness" of a curve. (yeah, its a bogus term... maybe "curviness"?)

Essentially, what I want to do is indicate how much "effort" there is to follow the curve. I.e., a curve with low bendiness would require less effort to follow than one with

*high* bendiness.

E.g., a bezier that is essentially *straight* would have no bendiness. OTOH, a curve that zigs and zags would have HIGH bendiness.

I have closed form solutions for the overall/cumulative "turning" that a curve experiences (e.g., a circle is 360 degrees of turning, an L is 90 degrees, a C is ~270 degrees, etc.).

Note that an S is bendier than a C -- and a figure-of-eight beats them all!

What I've come up with, so far, is to evaluate the tangent vector over the entire of the curve. I.e., this tells you which way the curve is "headed" at this instant.

Simultaneously, evaluate the derivative of the tangent vector to see how the tangent is *changing* at this instant. When the two coincide (for non-pathological cases), then the tangent is about to swing towards the other "side" of the curve -- i.e., a curve that had been turning "anticlockwise" is shifting to clockwise direction (if you were standing on the curve facing "forward", you'd previously been turning towards YOUR left and now are shifting to your RIGHT).

At this point, split the curve (de Casteljau). The bezier curve that is now "behind" you is guaranteed to consist solely of turns towards one "side" of the curve. Since it is also a cubic bezier, I have a closed form means for evaluating it's "bendiness". (assume the bendiness of a composite curve is the sum of the bendinesses of the component curves)

The curve ahead of you can contain, at most, one more of these points where the curve changes direction. Find it as above. Sum the two results.

This *seems* like it should work. The only possible problem I can see is for pathological cases like a cusp in the curve (where there is a discontinuity in the curve/tangent function).

Any other obvious vulnerabilities? Or, any more efficient algorithms? (this *seems* pretty straightforward... hard to imagine anything faster without constraining the curve itself)

Thx!

Reply to
Don Y
Loading thread data ...

What about just integrating the absolute value of the curvature, or perhaps the square of the curvature (to give more weight to tight curves)?

It seems less complicated than what you're proposing.

--
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
Why am I not happy that they have found common ground?

Tim Wescott, Communications, Control, Circuits & Software
http://www.wescottdesign.com
Reply to
Tim Wescott

You need to know where it changes *signs* (which is what I am effectively doing in the above). You also have to identify pathological cases and their points on the curve (e.g., cusps where the curve/derivative(s) become discontinuous)

I use a similar approach (curvature**2) for "jagginess".

The problem with all curvature based figures is they aren't intuitive. You can't *look* at one and get a "feel" for what it means in terms of the curve from which it was derived. It might be *more* useful if you are trying to evaluate the stresses that a mechanism traversing the curve is likely to encounter, etc. But, you couldn't easily/effectively convey to a third party how curves having characteristics of K and 2*K relate to each other.

OTOH, a person can understand that an S is twice as "bendy" as a C -- comparable to an O. M and W are comparably "jagged" and each roughly twice as jagged as an N.

[of course, I'm using glyphs simply because they are easier to "draw" in a text document than a real curve would be!]

How would you relate O and W using *your* metric? I.e., depending on the exact details of the path that the W traces, it is

*roughly* as "bendy" as an O (e.g., three 120 degree turns).

OTOH, the W is more *jagged* (separate measure) than an O. Or an L. etc.

Reply to
Don Y

It sounds like I answered your terms, but not the metrics you had in your head.

Perhaps you should quantify just what you really want?

--
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
Why am I not happy that they have found common ground?

Tim Wescott, Communications, Control, Circuits & Software
http://www.wescottdesign.com
Reply to
Tim Wescott

I want a metric that shows the "effort" (deliberately avoiding the word "work") required to follow a particular curve.

[imagine stylized versions of each of the glyphs referenced below]

The effort to follow a C is less than the effort to follow an O.

The effort to follow an S is equal to that of following an O.

The effort to follow a 9 is identical to the effort required to follow a 6.

The effort to follow a V is half what is required to follow an N.

The effort to follow a W is ~thrice required for a V.

The effort to follow a U is the same as that for a V.

The effort for a W is roughly the same as that of an O.

The effort required for a "heart" is roughly the same as an S plus an L (think about it).

An e is roughly the same as an o.

etc.

I.e., imagine you were piloting a boat, driving a car, moving a cutting head on a CNC machine, etc. The effort to make a '-' vs. a '/' is the same -- both are "pick a direction and go!" (of course, the *work* involved in the latter is more than the former -- but, we're not addressing that, here)

Now, consider the same exercise with a C, a circle (O) and an S. The latter two have roughly twice the "bending" that the former has -- though the bending in the S "changes sign" halfway through.

A C and a U have comparable efforts -- the U might have a tighter radius in the middle (higher curvature) but offsets that with periods of little/no curvature.

Using curvature, per se (as mathematically defined) poses problems because the tightness of the curve comes into play. A V and a U would exhibit different results (imagine the V being drawn with the uprights truly parallel).

Curvature measures also get upset with discontinuities in the curve -- curvature becomes infinite at the vertex of the 'V'.

OTOH, a non-technical user would be able to "relate to" N being twice as "bendy" as V and M being three times, etc. (It's not really the number of angles, there, but, rather, the sum of the absolute values of the angles...). You can understand that piloting a ship in an S-shaped waterway would require roughly the same amount of effort (attention/control?) as it would for an O-shaped waterway. Mowing a W-shaped lawn would require ~three times the effort of a V-shaped one...

And, you wouldn't have to take out a calculator to convince the non-technical user of these facts!

If there was a name for it, I wouldn't call it "bendiness" :>

Reply to
Don Y

What's so wrong with calling it by the name it already has: curvature?

Insufficient condition. It might just as well be straightening out just to return to being curved the same way round as before...

Which seems to be pretty much exactly what you're proposing to do, isn't it? That splitting point you construct is (or rather: tries to be) exactly the place where curvature changes sign. Your definition just misses the case where curvature touches zero without crossing it.

I'm afraid I have to call BS on that one. Curvature (properly defined) is the simplest and most intuitive way to describe a curve's shape there is: fit a circle into the curve at the point of interest, and there you go: curvature is the inverse radius of that circle. It's as simple as that.

But the term you really seem to be looking for is total angle-of-turning.

Reply to
Hans-Bernhard Bröker

That definition is still quite flawed. "Follow" --- how? Follow that curve as such, or its particular parametrization given by the Bezier spline? "Effort" --- assuming what kind of device?

Only if by '-' vs. '/' you meant 'flat' vs. 'uphill' --- which is by no means clear from the symbols. You could equally well have meant 'east' vs. 'north-east'.

Not if they're the same actual size as those latters, and you actually have to drive those bends. That s has curves twice as sharp as the O. You'll notice by you having to turn the steering wheel much further (and without power steering, more forcefully, too), and by the tires squealing a good deal more in the 'S'-shaped track if you drive both shapes at the same speed.

So does your attempted definition --- no tangent vector, no derivative of the tangent, so no vectors to check for being parallel.

Actually, no. I can't understand that, because it simply isn't true. Driving an O takes effort once --- turn the wheel, lock it, and that's it. To drive an S, you have to turn the wheel both more often and more extremely. No way does that classify as the same amount of effort.

Reply to
Hans-Bernhard Bröker

I must not have been clear. Integrate the absolute value of the curvature _per unit length_. You should get a number that's the total amount of turning involved (in fact, I'm pretty sure you'll get it in radians, and it'll be exactly 2*pi for any closed, strictly convex figure).

For things with sharp corners you'll have to appeal to the Dirac delta functional and say that the integral across the sharp corner is equal to the angle turned, without fessing up to knowing any details in the (infinitesimal) length of the actual corner.

--
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
Why am I not happy that they have found common ground?

Tim Wescott, Communications, Control, Circuits & Software
http://www.wescottdesign.com
Reply to
Tim Wescott

Because it's *not* curvature. First, curvature only applies to a point on a curve. So, you need to integrate it, at least.

Look at a cubic bezier. Show me a case where this is true.

See above. Show me how the tan x tan' = 0 and the curve NOT "bend to the other side".

So, a small circle has more curvature than a large circle. Right?

Now you are tying another characteristic of the curve in with this one -- namely, "size".

To be clear:

c has the same "bendiness" as C. o has the same as O. (there aren't a lot of glyphs to choose from for other examples) e as O/S/s/ etc.

That's what I am CURRENTLY implementing -- as well as describing a means by which I can get that result in deterministic time for arbitrary, unconstrained cubic beziers.

But, I have also opened the door for *alternative* definitions of "bendiness" THAT SATISFY THE EXAMPLES I HAVE SHOWN in other posts.

I.e., if you can't *look* at two shapes and tell me that they have "similar bendinesses", then you probably won't be able to convince a non-technical user of that, either!

(by contrast, the scheme I proposed *can* be explained on a napkin)

Reply to
Don Y

Wow, you really insist that the world have N decimal digits in it! When you come across a sign that says "curve ahead", do you expect it to also carry an annotation of the turning radius of that curve? If the sign says "falling rocks", do you need to know from what *height* they are likely to fall?

Look at an 8. Using any *sane* concept of "follow" (with your eyes; tracing with your fingers; driving on a vehicle; etc.), is MORE or LESS effort required to "follow" it than, for example, an *O*?

If you can't answer this question honestly, you don't belong in the conversation -- because the people who *will* be evaluating these parameters *will* be able to see the 8 as more "bendy" than the O!

No. '-' is shorter than '/'. I don't have a choice of several OBVIOUSLY DIFFERENT LENGTH glyphs that appear to be straight lines on this keyboard.

The point is, both "curves" require the same amount of "effort" (NOT WORK!). They each share the same degree of "bendiness"

No, that's only true if you put some constraints on the *size* of each curve. Size is a different characteristic of a curve. Bendiness is a characteristic that exists independantly of size.

You've decided to normalize based on size. Should you, instead, normalize based on curve length? I.e., tying in any other characteristics makes the resulting characterization a *composite* one.

Think of bendiness as one axis in an N-space that describes the universe of curves. Size can be another. Jagginess a third. Curve length a fourth. etc.

See above.

"lock it" implies that there is some force that wants to *change* the position of the wheel! (even if the wheel would HOLD that position without the "lock", that just means "something" is making the "effort" on your behalf)

Why not load the ship on the back of a barge, turn off the engines, set the wheel any-which-way... then, from the ship's perspective, ALL courses are equivalent!

Reply to
Don Y

A further clarification...

Actually, I am implementing (signed) total ABSOLUTE angle-of-turning.

*Total* angle-of-turning for an S would be very different.
Reply to
Don Y

That's essentially what I am doing. You identify the places where the curve "bends" the other way (curvature changes sign). Splitting the curve at these points is trivial. The "total angle" spanned over that segment of the curve is readily computed from the tangents at start and end (which can be easily computed "on inspection").

A (cubic) bezier ends up sliced into at most three such curves. The signs of the total angles will be +-+ or -+- in the case of three curves; +- or -+ for two curves; and + or - for single curves that consistently bend in the same "direction". Each "subcurve" bends in just one "direction".

The behavior at the "split points" is easily inspected (you know which direction the "next" bezier starts off "facing" so can tell if you've encountered a cusp). The angle at that point is obvious from the ending tangent of the previous "subcurve" and the starting tangent of the *next* "subcurve"

The analysis doesn't care about scale, orientation, translation, etc. o == O, s == S, etc.

Reply to
Don Y

It may take a force to hold the wheel at that point, but it takes no more work (force x distance).

Perhaps a metric of pathlength traveled * turning effort per unit pathlength would be appropriate. Turning effort might be the absolute value of degrees of steering wheel turn in the distance. A circular path would have no effort after the start. Reversing turn direction in an S curve would have twice the effort of just transitioning to a straight line. This mechanical metaphor would have to have a minimum turn radius (or maximum effort) for "W" type paths.

Mark Borgerson

Reply to
Mark Borgerson

Note that I intentionally avoided (and explained my avoidance of) the word "work". "Effort" is intentionally vague so it can be defined in whatever bogounits seem appropriate TO THE MEASURE ULTIMATELY ADOPTED!

That would be a different sort of measure. I.e., an O and an S would have very different metrics -- despite the fact that an S can be regarded as an O that has been split and translated.

And, a C would have the same metric as an O. (as well as the overall size of the curve affecting the value of the metric) Is a small *tight* circle "bendier" than a larger, more graceful (circular) curve?

It's a tough metric to create because there are no "standards" to fall back on.

But that's true of many real-world issues. How do you evaluate the quality of the eraser on a pencil? Or, the durability of an enamel paint on a surface?

*And*, how do you convey those evaluations to non-technical users? E.g., a tire purchaser cares little about the durometer of a particular tire. Or, how brittle it might become in prolonged subzero temperatures. Rather, he thinks in terms of the total mileage he can be expected to get from the tire in its normal service life. A 100,000 mile tire is "twice as good" (?) as a 50,000 mile tire (assuming, of course, the same rating scheme is used for each tire). He can make real use of that metric vs. the radius of a circle tangent to a particular point along a funny shaped curve...

Metrics that aren't linear are harder for people to relate to unless the characteristic they are measuring inherently maps to that non-linear representation. E.g., a 2-dimensional quality could possibly be characterized by a second-order metric -- e.g., area encompassed by the curve.

Imagine sitting in a bar trying to explain the concept of "bendiness" to a "normal person". It's a lead-pipe cinch to show how an N is twice as "bendy" (whatever THAT means) as a V -- draw a V, draw a second one upside down, superimpose them...

Or, how an e and an o are the same: draw an e on a napkin WITHOUT LETTING THE OTHER PERSON SEE THE NAPKIN (i.e., they just watch the motions of the back end of the pen); now repeat drawing an o -- if you choose the trajectory carefully, the other party will be (essentially) unable to tell which figure you've drawn. I.e., they *feel* similar.

Similarly, drawing an 8 vs an O makes the fact that the 8 is twice as "bendy" pretty obvious in the "effort" the pen tip conveys.

Reply to
Don Y

What that actually means it that this is one more aspect of your proposed definition that, so far, you totally failed to so much as mention: invariance under scaling.

And guess what: that's exactly what you would get by integrating absolute curvature along the curve.

Nobody can tell you that, because you've still not actually managed to explain what _your_ term "bendiness" actually means.

Hmm... an interesting claim you make after having failed to do just that.

Reply to
Hans-Bernhard Bröker

When you describe SIZE, does it also involve COLOR? When you describe MASS/WEIGHT, does it also involve SCENT? When you describe LENGTH, does it also involve SHAPE? When you describe DISTANCE, does it also involve BEARING?

You seem to insist on having every little detail nailed down before you can even approach a problem. Do you have an issue with "abstract thought"?

"Bendiness" is an abstract concept. Like distance. It is orthogonal to other concepts -- like jagginess (I seem to recall mentioning this, earlier. Perhaps you weren't in class on that day??). It has no existing units of measure -- because I am trying to *define* it. And, define it in a way that "non-technical" people would be able to relate! Which also suggests that it's measure is *likely* to be straightforward.

[or, at the very least, a non-technical person encountering metrics for two different curves should be able to convince himself that the metrics "feel correct" -- or not. Like the total on the cash register at the grocery store when you've made a purchase; perhaps you can't vouch for every digit to the right of the decimal *but* the number *feels* to be in the right ballpark!]

You could, for example, say "bendiness is the number of changes of directions" -- sounds like a plausible definition, eh? But, given that these are cubic beziers, we already know that the "bendiness" for any curve will be 0, 1, or 2. Hardly an effective metric to cover the wide range of curves representable with a cubic bezier!

E.g., a "2" could appear to *almost* resemble a straight line. Like the walk of someone "slightly tipsy". *Or*, it could resemble a smooth 'Z' -- with wide excursions to either side like a stone cold drunk!

OK, so maybe the convex hull is a better measure? Since it has to be reduced to a single metric, perhaps the aspect ratio of the bounding box of the convex hull?? (oh, yeah... I can see explaining THIS to someone on the back of a napkin at a bar! :> )

But, an S and a C shaped bezier could have similar/identical metrics (bounding-box-of-convex-hull-aspect-ratios). Yet, "clearly" (at least, to *me*!), an S is "bendier" than a C.

Of course, you could also simply provide the control points to the other party and say "this is how bendy the curve is" (and count on *them* to instantiate the curve and apply THEIR OWN criteria to define its bendiness!) Sort of like answering the query "How much do you weigh?" by climbing on their SHOULDERS and letting *them* evaluate your weight in whatever notion they use for "weight"!

Integrating |curvature| requires the curve to be "well behaved". And, requires you to essentially perform the same operations that *I* have described *geometrically* in my original post.

You can get total absolute angle a lot more directly from a cubic bezier if you know the curve to be a "0". And, splitting the curve as I describe *ensures* each subcurve *is* a "0".

I've given specific examples of how a "bendiness" characteristic should respond to a range of potential shapes.

You seem to want me to say, "bendiness is the integral of the total force exerted by a coil spring (having spring constant K) to keep a diamond tipped stylus attached to the end of a 12" stainless steel arm centered in a 0.06" wide channel of the prescribed shape cut into a nickel plate to a depth of 0.10" as it is moved at a rate of V through the measurement apparatus."

Or somesuch.

OTOH, Joe The Bartender knows 8 is twice as "bendy" as O. He might not be able to put a number on it *or* know what the units of measure are. And, he doesn't even *think* about how LARGE the O is, nor the 8. You wouldn't stump him if you rolled the 8 onto its side -- he'd *still* tell you it was twice as bendy! If you colored it *red* and the O blue, you'd still not manage to confuse him! If you fashioned the likeness of one out of a titanium alloy and the other out of a wet spaghetti noodle, he'd remain confident in his answer. Cover one with tabasco sauce and the other with d'angostura bitters and his answer would be unchanged (though he might be annoyed at your waste of flavorings! If you held one up above your head and the other down at your feet, he'd just smile and give you the SAME ANSWER!

"Bendiness" is "bendiness" -- whatever *that* is!

Propose an alternative that satisfies the criteria I've (elsewhere) described...

Reply to
Don Y

that* is!

One possibility I've considered is the ratio of the length of the curving line to either the perimeter or the area of the enclosing convex hull. For a given area or perimeter, the more curved line you put in the area, the more 'curviness' you have.

Mark Borgerson

Reply to
Mark Borgerson

You could compare the length of the curve to the length of the line segment joining the endpoints -- a higher ratio means the line "bends more" (is less straight). But, if a curve does all of it's bending on one side of that start-finish line segment, is that more or less bendy than a curve OF THE SAME LENGTH that "wiggles" its way there?

Imagine how I would explain this to Joe The Bartender WITHOUT taking out a calculator and exposing him to a lot of advanced math ("Here, Joe, this is how you compute the actual length of a cubic bezier... and *this* is how we compute the length of a line between two points...")

There are a *lot* of metrics you can come up with. What's hard is coming up with something that "feels right" to a casual user.

And, few of them have any relationship to any "formal" parameters that mathematicians (e.g.) may have defined.

I've got a slew of "characteristics" with an equal number of totally *bogus* names -- bendiness, jagginess, roundaboutedness, curviness, "density", etc.

It's especially hard when the metric is of a different "order" than the thing it is purporting to measure.

[keeping in mind non-technical audiences]

E.g., what does it mean to make a curve "twice as big"? Look at how casually people use the term. If I make an 'A' twice as *tall* (without altering its width), it is "twice as big". OTOH, if I double *each* dimension (i.e., 4 times the area), people would ALSO call it "twice as big".

There are lots of bogus units that are readily embraced just because they *can* be related to their audiences easily. E.g., doctors think in terms of "pack-years" for tobacco consumption. They could just as easily have expressed this as "total cigarettes consumed" (a pack-year is essentially 7300 smokes). Note that they gloss over

*how* they are consumed (i.e., as a function of time) whereas you *know* that has to be significant. But, the simpler metric is easier to relate to patients and gives enough data that they can draw real conclusions (with some degree of confidence) from them.
Reply to
Don Y

Hi Don, I have been vaguely following this so I may just suggest the obvious but could you not simply integrate the absolute value of the second derivative of the curve? Should yield what you seem (to me.. :-) ) to be after.

Dimiter

------------------------------------------------------ Dimiter Popoff Transgalactic Instruments

formatting link

------------------------------------------------------

formatting link

Reply to
dp

I think he suggested that in his OP. It's the obvious solution as far as I can see (IOW, the "bendiness" of the curve is related to the acceleration needed to follow it), but Don doesn't seem to like it, for reasons I've not been able to quite understand.

Reply to
Robert Wessel

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.