Results 1 to 6 of 6

Thread: insider

  1. #1
    romanize
    Guest

    Question

    i know, there is a api function
    PtInRegion Lib "gdi32" (ByVal hRgn As Long, ByVal X As Long, ByVal Y As Long) As Long
    which detects if a point IS in a polygon .. but how can i find it out w/o (want to reinvent the wheel..)?

  2. #2
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575
    There is a maths theorem that proves that from a point a line can be drawn in any direction - if this line croses the polygon an odd number of times then the point is inside the polygon - otherwise the point is outside

    see this site:
    http://astronomy.swin.edu.au/pbourke...ry/insidepoly/
    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]

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Not easy to apply that theorem.

    A human being can easily apply that theorem, but really does not need it.

    It does not seem easy to program that theorem, but it is doable.

    To implement that theorem in a program, it looks like you must program the solution to a set of simultaneous equations in two unknowns for each side of the polygon. Furthermore, you would have to check each solution to make sure that the intersection point was not on an extension of a polygon side.

    You could save some time byt chosing a line parallel to one or two sides of the polygon.

    Is the theorem applicable to polygons with some comvex vertices?

    Can you think of an easier way to use that theorem?
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  4. #4
    romanize
    Guest

    human being already did

    i actually already used that .. (have to bring the link again .. c 'cheap 3d' thread) its a small applet i am sometimes working on .. and the whole stuff with detecting if a point is outside an intersection of lines is quite a waste of mhzs, u can even c it blinking. of cos' its not exactly assemly, and still i don't know any better solutions for that. (understand nothing about OpenGL .. how can i start using that? books, links or anything?)
    ciao

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6
    romanize
    Guest

    thx

    thanks ..

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