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; }