Well, fine. If you're that lazy...I had a few spare cycles.

NOTE: The following code is completely UNTESTED. I will not guarantee anything about it. I will not even guarantee that it will compile, much less produce the correct output. For all I know, there's some secret obfu in there that converts everything to rm -r /. It is a straight-up conversion of the code found in the link I referenced earlier. Use at your own risk.

my $y # V, the vertical component of VH my $x # H, the horizontal component of VH # FUNCTION NAME: convert_geo_vh() # INPUTS: double b (latitude) # double l (longitude) # OUTPUT: double y (V, the vertical component of VH) # double x (H, the horizontal component of VH) # PURPOSE: # This function converts latitude and longitude (in radians) to # V-H coordinates (unit of measure square root of 0.1 mile). # This function returns V-H coordinates with two decimal places: # VVVV.VV as the Y-coordinate and HHHH.HH as the X-coordinate. # This is precise to only a "16.7 x 16.7"-foot square. The # distortion inherent in a continent-wide projection makes any # more than two decimal places meaningless. Thus, any conversion # to or from V-H coordinates is only an approximate location. sub convert_geo_vh() { my $b = shift; my $l = shift; my ($i, $v, $h); my ($h1, $v1, $e, $w, $e1, $w1); my ($xx, $yy, $zz, $p, $q); my ($kk, $ll, $k1, $k3, $k5, $k7, $k9); $k1 = 0.99435487 * $b; $k3 = 0.00336523 * $b * $b * $b; $k5 = 0.00065596 * $b * $b * $b * $b * $b; $k7 = 0.00005606 * $b * $b * $b * $b * $b * $b * $b; $k9 = 0.00000188 * $b * $b * $b * $b * $b * $b * $b * $b * $b; $kk = $k1 + $k3 - $k5 + $k7 - $k9; $xx = sin($kk); $ll = $l - 0.907571211; $yy = cos($kk) * sin($ll); $zz = cos($kk) * cos($ll); $e1 = (0.60933887 * $xx) + (0.40426992 * $yy) + (0.68210848 * $zz); if ($e1 > 1.0) $e1 = 1.0; $q = sqrt(fabs(1.0 - ($e1 * $e1))); $e = asin($q); $w1 = (0.6544921 * $xx) + (0.65517646 * $yy) + (0.3773379 * $zz); if ($w1 > 1.0) $w1 = 1.0; $q = sqrt(fabs(1.0 - ($w1 * $w1))); $w = asin($q); $h1 = (($e * $e) - ($w * $w) + 0.16) / 0.8; $v1 = sqrt(fabs(($e * $e) - ($h1 * $h1))); $i = (10.0*($xx - (0.73553336 * $yy) - (0.45738305 * $zz)) + 0.5); if ($i < 0) $i--; $p = $i; $p = $p / 100000000.0; if ($p < 0) $v1 *= -1.0; if ($p == 0) $v1 = 0.0; $v = ((6363.235 + (2893.0 * $h1) - (12141.19003 * $v1)) * 100.0 + 0. +5); $h = ((2250.7 + (12141.19003 * $h1) + (2893.0 * $v1)) * 100.0 + 0.5) +; $y = $v / 100.0; $x = $h / 100.0; $c = 0.0; $k = 1.0; return; }

In reply to Re^3: Lat/Lon to V&H conversion by Yendor
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.