| 1 | # | ||
| 2 | # Coordinates system related functions | ||
| 3 | # | ||
| 4 | |||
| 5 | package OpenGL::Earth::Coords; | ||
| 6 | |||
| 7 | # (1/360.0) * 2 * 3.14159265 | ||
| 8 | 1 | ▶ | use constant DEG_TO_RAD => 0.0174532925; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | # Convert earth latitude/longitude to 3D coords | ||
| 11 | 3 | ▶ | sub earth_to_xyz ($$$) { |
|
Subroutine
earth_to_xyz: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 12 | 3 | my ($lat, $lon, $radius) = @_; | |
| 13 | |||
| 14 | 3 | $lat *= DEG_TO_RAD; | |
| 15 | 3 | $lon *= DEG_TO_RAD; | |
| 16 | |||
| 17 | 3 | my $cos_lat = $radius * cos($lat); | |
| 18 | |||
| 19 | 3 | my $x = $cos_lat * cos($lon); | |
| 20 | 3 | my $y = $cos_lat * sin($lon); | |
| 21 | 3 | my $z = $radius * sin($lat); | |
| 22 | |||
| 23 | 3 | return ($x, $y, $z); | |
| 24 | } | ||
| 25 | |||
| 26 | 1 | 1; | |
| 27 | |||
| 28 | __END__ | ||