The client now want to subtract a border of 0.05m from the shape.
This is ok it the polygon has a center that everything is going towards. But - if its a completly weird shape - you would not know in wich direction to move the point.
If its removing a area from any polygon that is always a 50mm (0.05m) from every polygon - is there not a way to take a proportional area off.
I've had 5 15 days on the project now... I can think anymore (but hallucinations are interesting (and legal).
Is there a geometry guru out there who can show me the light? (or the area)
If there is no efficient way, we can use brutal way. Plot another point for each corner point along the biset angle line for a calculated distance. Thus we get a smaller polygon. Calculate the small polygon area.
I did think of a possible solution, but I'm not sure that the maths is sound.
The pegs points are used to plot the area - all works great. I would like the proportially small area - then use the new shape as a hit test for some further calculations.
If I find the peg that if at one of the extents of the bounding box. Rotate the shape so that potint is nearest to 0,0. (it may already be the nearest) - then ajust that peg so that it is on 0,0 - and all the other pegs by the same amount.
We now have a polygon with its top left edge on 0,0. Now I just reduce the positions of every other peg by the margin amount - and recalculate the area.
Then I reposition the two shape so that they are centered.
What do you think, or are you laughing too hard to type?
However, for the circumstance you show in the gif, you will get the same result as mine. The inner lines are parallell to the original lines. The inner conrner is the intersect of those two new lines. So, the corner will be very sharp. The distance between old corner and new corner will be abnormally long. The result seems inevitable unless we try to "round" the corner, the way Flash handles the "stroke".
Oh, I thought that it would get round it because its moving the pges by lets say 20px.
On the image thanks.gif the peg would be closer to p2, than where it currently is (p6) - so when the lines were drawn the yellow streak would not go across.
A probablem I can already see with this is that the margin would not be consistant. (but hopefully in a uniform way that would not make the area calculated inacturate.
I just did a cursory skim of this thread, but couldn't you just find the perimeter, and multiply that by 0.05? We'll call that the "perimeter rectangle."
Subtract the perimeter rectangle from your original and you should have a very good estimate. If you need it more precise, you can find the angle of each corner, then find the overlap area from that.
If you subtract the overlap-area from perimeter-rectangle, then subtract that result from your original, I think you'd be nearly there.
Of course, if your corners are closer than 0.1, you'll have double overlaps...