+ Reply to Thread
Results 1 to 21 of 21

Check for xx-yy point inside/outside graphic area

  1. #1
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Question Check for xx-yy point inside/outside graphic area

    Hi there,

    I have an "small area" drawed inside a graphic, and when i add a position of "xx" and "yy" with a dot point, its possible to know if its inside that area or not, for example marking another cell saying "dot out of range area" ?

    Many thanks.
    Last edited by Blue_Wings; 09-04-2010 at 12:16 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    Post an example workbook that shows what you're doing, and explain in context.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by shg View Post
    Post an example workbook that shows what you're doing, and explain in context.
    In this example, Mark1 and Mark3 are both out of the area, can the letters "Mark1" and "Mark3" be modified to color red and bold ?

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Check for xx-yy point inside/outside graphic area

    This sounds like the beginning of the Monte Carlo method for determining area. Take random shots (x,y) coordinates and see how many of them hit vs miss the area. The area would be the same color of blob on a two dimensional graphic picture.

    A better question might be, Is there a way to take a pixel from a graphic and determine what color it is?

  5. #5
    Registered User
    Join Date
    08-29-2010
    Location
    Switzerland
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by shg View Post
    Post an example workbook that shows what you're doing, and explain in context.
    Since I'm helping Blue_Wings on this project, let me explain the context.

    We are working in a worksheet that calculates weight and balance for an aircraft according data entered by user. And what we want to do is to show an alert when aircraft actual data is outside flight envelope. To do so, we need to determine if the point we draw is inside or outside that envelope.

    Can anyone help us, please?

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Check for xx-yy point inside/outside graphic area

    It looks like this is not as exciting as the Monte Carlo method.
    You will need the criteria for each point (X,Y) coordinate against each of your lines in your example.

    It looks like the top line is Y<275000, bottom line is Y > 122500, left bottom line is Y < -6000X + 280000, etc. You would get the equation for each ine and then determine if it is < or > by tossing in point (0,0) and see which symbol works.

    Then generate your points and if it passed the test for each line (it looks like there is 7 of them), then it is inside your figure.

    If you need the area inside your figure it is a real easy formula if you have the coordinates of each vertex.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    I have a VBA routine to do this (somplace ...) if a UDF solution is acceptable.

  8. #8
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by MarvinP View Post
    It looks like this is not as exciting as the Monte Carlo method.
    You will need the criteria for each point (X,Y) coordinate against each of your lines in your example.

    It looks like the top line is Y<275000, bottom line is Y > 122500, left bottom line is Y < -6000X + 280000, etc. You would get the equation for each ine and then determine if it is < or > by tossing in point (0,0) and see which symbol works.

    Then generate your points and if it passed the test for each line (it looks like there is 7 of them), then it is inside your figure.

    If you need the area inside your figure it is a real easy formula if you have the coordinates of each vertex.
    Yes i need the area inside the figure, I am having some trouble thinking witch is the formula and where to put it, the vertex coordinates are 8 (x,y): (29,123000) (9,241000) (29,275000) (133,275000) (127,192000) (125,183000) (115,157900) (88,123000) if you dont mind to help a little bit more.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    Please Login or Register  to view this content.
    Line 20 duplicates the first point.

    The formula in F11 is

    =SUMPRODUCT(C12:C20 - C11:C19, D11:D19 + D12:D20) / 2

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Check for xx-yy point inside/outside graphic area

    Look at the picture on This Link

    The idea is that you take each line separately and use it as the top of a trapizoid with the X axis as the base.
    The area of each is the base (differences of the x coordinates) times the average of the y coordinates. You do this with each line segment and you add the areas on top and subtract the areas on the bottom, leaving the area of the irregular polygon. The link gives the example.

    Here is a better example of how easy it is. Click this link.
    Last edited by MarvinP; 08-29-2010 at 08:36 PM.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    See attached for a UDF approach.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    After the calculation of the area that you have in F11, now how can i test for example xx 50 and yy 220000 to see if its inside that area?
    Last edited by shg; 08-29-2010 at 11:55 PM. Reason: deleted spurious quote

  13. #13
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by shg View Post
    See attached for a UDF approach.
    Thanks a lot, it works.
    By the way... what does it means "UDF" ?

    Can you confirm that i dont really need the formula that calculates the total area ?
    Other thing... the excel is giving me an error #NAME? (in Portuguese) with the formula =Inside(), in your sheet works, but in mine dont work.
    I am trying to find the =Inside() in portuguese.
    Humm after some search i understand now... you made a formula with VBA.
    Its not possible to make something without VBA ? to be easier to understand.
    Last edited by Blue_Wings; 08-29-2010 at 11:53 PM.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    what does it means "UDF" ?
    User-defined function -- a function that can be invoked from the worksheet like a native Excel function.

  15. #15
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    In my excel sheet (excel 2007) i do alt+F11 to go to the Visual Basic Editor and then Insert > Module (copy paste your code in your module to my sheet) then "save", i went to the sheet to test the Inside() function but does not work, it just stays like this =Inside(N5;O5;F5:G13) and dont say "TRUE" or "FALSE" has is supose to.

    Where this formula is supose to "=Inside(X,Y,range)" i think

    Why it does not work ?
    thanks

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    Here are examples of using formulas and the UDF (the name of which was changed).
    it just stays like this =Inside(N5;O5;F5:G13)
    Sounds like the cell is formatted at Text. Change it to General.
    Attached Files Attached Files
    Last edited by shg; 08-30-2010 at 11:40 AM.

  17. #17
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by shg View Post
    See attached for a UDF approach.
    Hi shg,

    I think that now its all almost working, but i have a question, in some parts of the irregular polign area the test to see if the coordinates are inside gives output as FALSE when is supposed to give TRUE, can you tell me why please?


    the coordinates are: xx axxis 154
    yy axxis 155000

    the area is:
    X Axxis Y Axxis
    56 ----- 100000
    6 ----- 215000
    202 ----- 215000
    246 ----- 208000
    242 ----- 195500
    123 ----- 118000
    119 ----- 100000
    56 ----- 100000

    and the formula is: =Inside(B4;C4; $I$4:$J$11)

    where B4 is 154 and C4 is 155000 and $I$4:$J$11 is the area X Axxis Y Axxis discribed above...

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Check for xx-yy point inside/outside graphic area

    The polygon must be convex, and yours isn't (attachment). That requires a different algorithm. I'll try to provide a better function in the next few days.
    Attached Images Attached Images

  19. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Check for xx-yy point inside/outside graphic area

    Cheers
    Andy
    www.andypope.info

  20. #20
    Registered User
    Join Date
    03-20-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2019
    Posts
    69

    Re: Check for xx-yy point inside/outside graphic area

    Quote Originally Posted by Andy Pope View Post
    Yes thanks very much.
    And thank you too shg, if i find any problem i will tell you guys.

  21. #21
    Registered User
    Join Date
    03-31-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Check for xx-yy point inside/outside graphic area

    Hello everybody,

    I'm new here. Anyways, is anybody willing to help me with adapting this code for application on a logarithmic chart?

    The thing is, the chart must be in logarithmic scale, both X and Y axis to display data properly. And since there are some differences between normal division and logarithmic division, the function doesn't work properly.

    Could anybody help, please?

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1