algorithm - How can I generate echo path for concave polygon -


i need algorithm draw echo path arbitrary polygon. if polygon convex problem quite easy solve. understand mean please @ picture bellow in black original polygon , in red color echoed polygons generated original one. convex polygon echo demonstration

d distance between echo paths given

β angle easy calculate knowing coordinates of vertices have

so can see each vertex can calculate l , have new vertices next echo path.

the problem when have concave polygon @ point ugly picture of self crossing polygon. please take picture. enter image description here

what want generate echo polygon without self crossing part i.e. without part dash lines. algorithm or java code helpful. thanks.

edit

just adding piece of code generates echo path convex polygon asked in comment.

public list<mypath> createechococentral( list<point> pointsoriginal, float encoderechodistance, int appliqueechocount){      list<point> contourpoints = pointsoriginal;     list<mypath> echopaths = new arraylist<>();     (int round = 0; round < appliqueechocount; round++) {          list<point> echoedpoints = new arraylist<>();         int size = contourpoints.size()+1;//+1 because connect end start          point previouspoint = contourpoints.get(contourpoints.size() - 1);         (int = 0; < size; i++) {             point currentpoint;             if (i == contourpoints.size()) {                 currentpoint = new point(contourpoints.get(0));             } else {                 currentpoint = contourpoints.get(i);             }             final point nextpoint;             if (i + 1 == contourpoints.size()) {                 nextpoint = contourpoints.get(0);             } else if (i == contourpoints.size()) {                 nextpoint = contourpoints.get(1);             } else {                 nextpoint = contourpoints.get(i + 1);             }             if (currentpoint.x == previouspoint.x && currentpoint.y == previouspoint.y) continue;             if (currentpoint.x == nextpoint.x && currentpoint.y == nextpoint.y) continue;              // signs needed o determine side of polygon new point go             float currentslope = (float) (math.atan((previouspoint.y - currentpoint.y) / (previouspoint.x - currentpoint.x)));             float signx = math.signum((previouspoint.x - currentpoint.x));             float signy = math.signum((previouspoint.y - currentpoint.y));             signx = signx == 0 ? 1 : signx;             signy = signy == 0 ? 1 : signy;              float nextsignx = math.signum((currentpoint.x - nextpoint.x));             float nextsigny = math.signum((currentpoint.y - nextpoint.y));             nextsignx = nextsignx == 0 ? 1 : nextsignx;             nextsigny = nextsigny == 0 ? 1 : nextsigny;              float nextslope = (float) (math.atan((currentpoint.y - nextpoint.y) / (currentpoint.x - nextpoint.x)));             float nextsloped = (float) math.todegrees(nextslope);              //calculatemidangle - bit tricky function calculates angle between 2 adjacent edges             double s = calculatemidangle(currentslope, nextslope, signx, signy, nextsignx, nextsigny);             point p2 = new point();              double ew = encoderechodistance / math.cos(s - (math.pi / 2));             p2.x = (int) (currentpoint.x + (math.cos(currentslope - s)) * ew * signx);             p2.y = (int) (currentpoint.y + (math.sin(currentslope - s)) * ew * signx);              echoedpoints.add(p2);             previouspoint = currentpoint;           }          //createpathfrompoints creates mypath objects given poins set         echopaths.add(createpathfrompoints(echoedpoints));         //remove last point since connect end first point         echoedpoints.remove(echoedpoints.size() - 1);         contourpoints = echoedpoints;     }     return echopaths; } 

you looking straight skeleton:


          straightskeleton
          (image wikipedia.)



Comments