Introduction Algorithm Maths Area Tolerance Step by step Coding References Homepage |
Coding of the Algorithm
Step 1 - initializing the algorithmCalculate the overall area tolerance : Eo*Ao Next, compute E(u,1) and E(u,2) the allowable error associated with each side of the polygon using the equations detailed in the Area Tolerance section of this tutorial.
E(u,2) = Ao*Eo/P
Step 2Next, get the points which form a segment - randomly choose a starting point, let this be Ko, then choose the third point clockwise or anticlockwise to be K. This gives us our first line segment, [KoK] Initialise Ek and Ak to zero - these will be calculated in Step 3.
Step 3WHILE K<=N (*this section makes the approximating segment larger until the area tolerance is exceeded*)
2. Update Ak 3. IF Ak<=Ek THEN let K+1=K (* extending the approximating segment)
1.Make point K-1 part of the smoothed polygon 2.Reset the approximating segment, let Ko = K-1; let K=K+1 3. Initialise Ek and Ak to zero again. Output(K-1)th point.( * this is the last part as the number of points in the line segment has reached the number of points in the polygon *) EXIT |
---|