I
I
ivanesi2015-02-18 20:00:50
JavaScript
ivanesi, 2015-02-18 20:00:50

How to compare the shape of bezier curves?

Tell me where to dig to write an algorithm for comparing curves, or poke into a ready-made solution.
The coordinates of points and anchors are known. These coordinates for the two compared curves do not match. The number of points on the curve can also be different. It is necessary to compare the form. For true, the shape should "roughly" match.
I found $1 recognizer, but as I understand it, it does not work with Bezier curves.
Please see the picture:
8256e536c9ce4f01bf12d792473038d5.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sumor, 2015-02-18
@Sumor

The curvature depends on the signs of the second derivative. If you have several connected Bezier curves, then the second derivative may not exist at the boundary.
If cubic Bezier curves are used, then the second derivative is a linear function. Therefore, for one segment there may be options:
1. The second derivative is positive.
2. The second derivative is negative.
3. The second derivative changes sign from plus to minus.
4. The second derivative changes sign from minus to plus.
Therefore, in order to compare two curves consisting of several Bézier curves, it is possible to classify each segment of each curve by the form of the second derivative and compare the classification.

S
SeptiM, 2015-02-18
@SeptiM

If I understand correctly, you want to compare up to curvature. I would parametric the curve and take the second derivative d^2 f / dt^2. At each point, this will be the normal to the curve. It is necessary for each curve to write down a sequence when this normal is on the left of the curve, when it is zero (the curve goes straight or an inflection point), when it is on the right. You will get such a line, for example, +1,0,-1,...,1. Well, compare them.
The sign can be obtained, for example, by counting the determinant a 2x2 matrix composed of vectors for the first and second derivatives. You can try to do it numerically first. If appropriate, try to solve analytically.

A
An, 2015-02-18
@Flanker_4

If you need a recognizer for only two shapes
"( "
and
"~"
Then you can simply build a line between the start and end points of the curve, and then check whether all anchors are on the same side of the line [So we have "(" ] or not [ Means "~"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question