dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: Area of polygon - then something extra

Hybrid View

  1. #1
    Random logic?
    Join Date
    Oct 2000
    Posts
    410

    Area of polygon - then something extra

    Hi, I am doing a tool that works out the area of a room - and displays the value.

    It uses the following equasion:
    http://www.attewode.com/Calculus/Are...ement/area.htm

    Which works great and I get my figure.

    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)

    M@?

  2. #2
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    sorry - might be more helpful if the url was correct:
    http://www.attewode.com/Calculus/Are...ement/area.htm

    Its only for background - what i'm ultimatly after is a way of manipulating the calculated area to take of the area when you add a margin of x...

    M@

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    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.
    Attached Files Attached Files

  4. #4
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    Hi Ericlin,
    Thanks so much for taking the time to respond to the challenge.

    This method is great, exept in one citcomstance:
    http://www.3ainteractive.com/thanks.gif

    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?

    M@)

  5. #5
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Yes, you can do that.

    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".

  6. #6
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    Hi ericlin,

    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.

    PS: The shape is almost important as the area...

    M@)

  7. #7
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    I dont quite understand how you round the angle by shifting pixels. When I say "round", I mean a "curved" corner.

    On the graph thanks.gif, could you draw out by hand the ideal smaller area you need ? So that I can modify the codes to do the job you expect.

    There are 3 types of line joining to draw the corner. The picture below is from the web page:
    http://studio.imagemagick.org/RMagick/draw.html
    Attached Images Attached Images

  8. #8
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    Hi ericlin,
    this is what I'm trying to achive:
    http://www.3ainteractive.com/thanks.gif

    M@)

  9. #9
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    That seems to be the old picture ?! I do not see any difference ?!

  10. #10

  11. #11
    Senior Member
    Join Date
    May 2001
    Posts
    1,838

    OK, that is a round corner.

    I will try. If I get something, I will post here.

  12. #12
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    I understand - I think.

    Note that the solution - if any has to be flash 6 player compatible...

    Will go thorugh your original code to understand any differences with my engine.

    M@)..

  13. #13
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Here is a try.

    The area should subtract the arc part.
    Attached Files Attached Files

  14. #14
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    this is exactly what I am after - although my code does alot of other custom stuff - so I think there will be some kind of bast-ard child produced...

    Thank you so much.

    Can I email you a question if nec?

    My email is matt at 3ainteractive dot com
    (also my .NET passport))

    Whats yours?

    M@

  15. #15
    Senior Member
    Join Date
    May 2001
    Posts
    1,838

  16. #16
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    I tried emailing you - but it said that replaying is denied...

    ---------------------------------------------------------------------

    I am trying to integrate it with my code at the moment.

    I pass my function the coordinates of the points - it then draws the shape.

    I am trying to edit your function:
    (and use getInletPoint)

    I have a peg array too, but mine only has 2 dimensions. The x and y pos of each peg.

    I am going to try and pass your function, my peg co-ordinates - then try and get the new (smaller peg coordinates) in the 'inletArray' array.

    Do I need to use the roundAngleArray for what I want to do?

    M@?)

  17. #17
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    Got half way there.

    Yours runs round clockwise from the top left peg.

    Mine runs anticlockwise from the bottom right.

    Hmmmmmmmmmmm

  18. #18
    Random logic?
    Join Date
    Oct 2000
    Posts
    410
    Ignore me - I'm not reading properly. Less beer more concentration.

    I just have to fidle with the function to change the direction and starting point.

    M@

  19. #19
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    My email address in upper case is:
    ERICLIN@MS1.HINET.NET

    It is easy to mess "one" and "L" in lower case.

    It is lunch time now in office. I can only get my email after I am home in the evening.

  20. #20
    Member
    Join Date
    May 2002
    Posts
    97
    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...

    Just a new way to approach it, is all.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center