Does anyone have a program (preferably in C++) that can look at a polygon and return another polygon around it or inside it - offset by a certain amount.
Thanks
Rob
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
Hmm, although this is the maths forum, I think you're in the wrong place, doh Programming hardly ever seems to come up here. Try the general forum or the C++ one at that...
i can probably help you if you explain yourself a little better
Massey RuleZ! ^-^__Cheers!__^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
If the new shape is outside your polygon, then you won't get a polygon actually.
When a point of the polygon sticks out, and you buffer it, you'll get an arc. So, you'll get a shape which consists of lines and arcs.
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
plenderj - I can't find the center point and apply your rules because if the polygons center or centroid is not inside the polygon then the rules fail.
Thanks
Rob
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
BTW, I think you should prefilter your points to make sure you
don't have two {or more } successive points with the same coordinates, and
you don't have 3 {Or More} successive points that lie on the same line.
Obviously, if you have 3 successive linear points, you only need
the first and third for your poly, and obviously if you have
two or more successive points with identical coordinates, you
only need 1.
I believe those conditions are what causes the division by zero.
Also, you might want to know beforehand, what Offset Distance values will build
a poly "inside" vrs "outside" your original.
I beleive the best way would be a negative value should be the indicator for the progie to build outside, and Positive would be "inside". Build a preflight loop into the code, and have it build a Poly2 only slightly different with an Offset Distance value of, oh, lets say 10.
Once it builds the Preflight Poly2, it measures the total Point to Point distance of Poly2's perimeter, and Compares it to the original. Obviously, if the perimiter is smaller, then Positive values build inside, else if it was larger, then Negative values build inside.
So then it would automatically calibrate itself to change the sign of the input value you've entered to build Poly2 in the right direction.
BTW, You can't rely on measuring Poly2's perimiter to determine if Poly2 is inside vrs Outside, for large values of Offset Distance Input. Poly2 turns itself inside out when building inwards, and starts growing again.
And, 1 Last Thing. The Offset Distance Value is Not a direct measurement of how far away poly2 is from your original poly.
Its a measure of how far away their Vertice with index Zero Are from each other.
If you need to have the Offset Distance Value represent the
Exact Perpendicular distance from Wall to Wall2, well, you'll have
to tweak the code a bit, to determine MyPoly2(0) a little
differently.
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]