BTW, how would you want to treat the case where a whole (i.e. non-contiguous polygon) might be created?
Main Topics
Browse All TopicsI have a function to calculate a polygon which is outset a fixed distance from an input polygon (Fig 1). My function operates on a vector representing the input polygon by taking three consecutive vertexes and calculating new vertexes based on them.
For colinear vertexes it does not output any vertex.
For convex vertexes it calculates an arc of vertexes around the input vertex (Shown below)
For concave vertexes it calculates the intersection point of two lines offset from the segments described by the two vertexes. In Fig 2, The line AB becomes DE, the line BC becomes FG, the intersect of DE with FG (marked H) is the new vertex.
My problem is that the convex vertex C produces the new vertexes around K (circled green). which are too close to AB. The correct output would eliminate the vertexes around K, eliminate vertex H and add a new vertex at M.
The Figures below give a clearer explanation of the problem.
My program already has OpenGL tessalator functions available for CSG, which might be useful, but a pure solution would be much better.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
As you have noticed, for convex polygons, the algorithm solves the problem properly. For some non convex polygons solves quite well also. So, let me suggest to first classify the polygon as convex and non convex. This can be done simply finding the convex hull of the polygon. If the number of points of both polygon and convex hull the same, the the polygon is a convex one, then a simple algortithm solves the problem.
The non convex section (or more than one section) is the one with the sequential points which aren't in the convex hull (red), as the black lines in Fig. 1.
For non convex polygons, one of the approaches is to check the relative position of the intersections, which are different for external angles <180 degrees, as the ones at vertices 1 and 4, at Fig. 2.
At Fig. 2a, the point c, in red, appears after the line (b1,b2), thus showing that (b2,b3) is the line of the "contour" polygon { b1, b2, ..., bn } and (b2,b3) is the next line. As matter of checking, point c will be in the line (b1,b2) but with a factor of less than zero or greater than one, relative to the segment (b1,b2).
At Fig. 2b, point c is between (b1,b2) thus showing that point c replaces both b2 and b3 in the "contour" polygon.
Depending on the next condiction, say, if the angle at point 4 had less than 180 degrees, then another similar situation would repeat and the new point c is the intersection of (b1,b2) with (b5,b6) as in Fig. 3.
Jose
Business Accounts
Answer for Membership
by: BitlabPosted on 2009-09-30 at 00:22:04ID: 25456226
Hello FalconZero.
There are questions and draft of required algorithm: http://landkey.net/d/A/Pol ygons/outs et_poligon .png
Possibly this library or its ideas can be used: http://landkey.net/d/z/Ess ays/Polygo nsIntersec tion/S/Pol y.cs.htm
in section "Auxiliary mehods for polylines. "
Apparenlty, the problem you pictured is that your algorithm do not check that point K and its segment is already in internity of P' while BF and FG have been drawing.
Hope to be helpful, Konstantin.