algorithm - Trace a shape into a polygon of max n sides -
I am looking for an algorithm that will get an irregular shape, probably not random, such as the crushing cycle Detects a polygon of maximum N sides around the surface, and around the shape. 'N' can be based on the area of maximimum size.
I will do it like this
-
ang touch and dang for all curve segments, measure tangent angles
For this you or
atan2 Can use
ang [i] = accent (x [i] -x [i-1], y [i] -y [i-1]); Dang [I] = Ang [Ii] -ang [I-1];
Dang
Find Invex Point (Black)
Code> is changing at these points Then
Dang [i-1] * Dang [i + 1] is & lt; 0.0
but you need to handle the code> dang = 0.0 element properly (before and after it needs to be scanned).
Add maximum number (green) to these points
This point will be a fundamental skeleton for your point Tangent angle is among the closest differences, in order to find the maximum point between the index number
i0 and
i1
the nearest angle to angavg Find = 0.5 * (ang [i0] + ang [i1])
Do not forget that
| Ang [i] -gang & Lt; = PI
then
+/- 2.0 * PI if this is not true
Now You should have all the important points of your closed polycurve ...
It should look like this:
CW / CCW or red / blue bus
dang [ii] ... [Notes]
The output point type must be protected (Inks / MaxPoint) because it is used to compare and detect the shapes later on. A used ...
Comments
Post a Comment