Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I have a world map with world events (like volcanoes, earthquakes, hurricanes, etc.) mapped on it. I also have buildings (like the Empire State Building) mapped on it. I can determine through simple math if an event is within N miles of a building. I've done this in Perl and translated the math to a mysql function, since these calculations are done at the database level.

But now I have a more complex sort of "building" to map. This isn't a building in a single place, it's essentially a path, like for a pipeline. The pipeline is defined by its vertices: every place the pipeline changes direction is a vertex (obviously).

I want to determine now if an event is within N miles of this "pipeline". However, this is more than just checking each individual vertex of the pipeline, because it is possible for the event to be too far from a vertex to register a hit, yet close enough to a line drawn between the two vertices (which is the actual pipeline).

I sort of know the math for this situation... I need to test for a point (X0,Y0) on the line from (X1,Y1) to (X2,Y2) -- that's the pipeline -- that is on the perimeter of a circle of radius R from point (X3,Y3) -- that's the event. But I'm not sure I know how to convert that into lat/lng math for use in mysql. Any pointers?


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
Nos autem praedicamus Christum crucifixum (1 Cor. 1:23) - The Cross Reference (My Blog)

In reply to Algorithm: point with N distance of a line between two other points by japhy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (4)
    As of 2020-07-03 19:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?