Do you really need to convert back again ? If you are converting them from Lat/Long in the first place why not maintain a hash (or tied db if too many for hash) keyed on V&H of each Lat/Long you convert ? This assumes you are not performing any transformations of the resultant V&H only calculating various mileage distances as given above.

The other possibility is to calculate mileage directly from the Lat/Long pairs, this is not too hard (I can't remember the formula now but look up spherical geometry or celestial navigation (as in with a sextant, not for spacecraft :-) You can solve a spherical triangle based on the angle your two points make with one of the poles and the distance between each point and the pole (90-Lat)*CircEarth/360(in your desired units).

# why is there not a <pseudocode> tag :) ? # here is the triangle we solve... # # A (North Pole) # / \ # c b # / \ # B---a---C # # Point A is the north pole, B an C are all yours # $pointB $latB, $longB # $pointC $latC, $longC # here is the formula # cos a = cos b * cos c + sin b * sin c + cos A $miles_per_degree=$Earths_Circumference/360; $Angle_A=abs($longB - $longC); # needs fix for wrapping round the prim +e meridian $Len_b = (90-LongC)*$miles_per_degree; # fix for south of equator $Len_c = (90-LongB)*$miles_per_degree; # make degrees S negative ? # plug those three into the spherical circle equasion

Cheers,
R.


In reply to Re: Lat/Lon to V&H conversion by Random_Walk
in thread Lat/Lon to V&H conversion by jcoxen

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, details, 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, summary, 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.