Skip Menu |

This queue is for tickets about the Math-Complex CPAN distribution.

Report information
The Basics
Id: 34269
Status: resolved
Priority: 0/
Queue: Math-Complex

People
Owner: Nobody in particular
Requestors: om [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Math::Trig::great_circle_destination
Date: Thu, 20 Mar 2008 01:56:05 +0200
To: bug-Math-Complex [...] rt.cpan.org
From: "Otto J. Makela" <om [...] iki.fi>
It seems Math::Trig::great_circle_destination has some weirdness? The following code is based on the manual page example, which work fine, but my call to great_circle_destination ends up with a strange phi value. To be exact, phi seems to be 90° wrong, maybe the inverse of substracting this value done in the NESW function isn't done before returning, as just doing a rad2deg of the value returned seems to give the right number? ---- code ---- #!/usr/bin/perl -w use strict; use Math::Trig qw(deg2rad rad2deg :pi :great_circle); # Notice the 90 - latitude: phi zero is at the North Pole. sub NESW { deg2rad($_[0]), deg2rad(90 - $_[1]) } my @L = NESW( -0.5, 51.3); my @T = NESW(139.8, 35.7); printf("L=%.4f,%.4f\n",@L); printf("T=%.4f,%.4f\n",@T); my $dist = great_circle_distance(@L, @T); # About 9600 km. printf("dist=%.4f (%.0f km)\n",$dist,6378*$dist); my $rad = great_circle_direction(@L, @T); # About 0.547 or 0.174 pi. printf("rad=%.3f (%.3f pi, %.1f deg)\n",$rad,$rad/pi,rad2deg($rad)); # What's this, we don't end up in Tokyo using the calculated $rad and $dist? my @D=great_circle_destination(@L,$rad,$dist); printf("D=%.4f,%.4f (%.4f) %.1f,%.1f\n",@D,rad2deg($D[0]),rad2deg($D[1])); # It would seem that the 90 degree conversion done in NESW is neglected? Show quoted text
---- output ---- L=-0.0087,0.6754 T=2.4400,0.9477 dist=1.5060 (9605 km) rad=0.547 (0.174 pi, 31.3 deg) D=2.4400,0.6231 (2.7006) 139.8,35.7 -- /* * * Otto J. Makela <om@iki.fi> * * * * * * * * * * * * * * * */ /* Phone: +358 40 765 5772, FAX: +358 42 7655772, ICBM: 60N 25E */ /* Mail: Mechelininkatu 26 B 27, FI-00100 Helsinki, FINLAND */ /* * * Computers Rule 01001111 01001011 * * * * * * * * * * * * */
Unless I'm mistaken it's not possible to go from A to B like that because the bearing keeps changing along a great circle (except in special cases like meridians).