(20S and 21S) Great Circle - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (20S and 21S) Great Circle (/thread-8453.html) |
(20S and 21S) Great Circle - Eddie W. Shore - 06-03-2017 08:42 PM The following program calculates the distance between two places on Earth (or any other planet) given the coordinates latitude (λ, east is positive) and longitude (ϕ, north is positive). Inputs: R1: longitude 1, R2: latitude 1 R4: longitude 2, R5: latitude 2 Enter the coordinates in DD.MMSSSS. R1, R4: ϕ1, ϕ2; R2, R5: λ1, λ2 Distance, in miles, is stored in R0. Degrees mode is set. Formula: distance = acos( sin ϕ1 * sin ϕ2 + cos ϕ1 * cos ϕ2 * cos (λ2 – λ1) )* 3958.75 * π/180 On the HP 20S and HP 21S, can multiply by π/180 by executing the >RAD function. HP 20S and HP 21S Program: Great Circle Code:
Example 1: Los Angeles to Rome: Los Angeles (ϕ1 = 34°13’, λ1 = -118°15’) Rome (ϕ2 = 41°15’, λ2 = 12°30’) Result: 6322.2196 mi Example 2: Dublin to Las Vegas: Dublin (ϕ1 = 53°20’52”, λ1 = -6°15’35”) Las Vegas (ϕ2 = 36°10’30”, λ2 = -115°08’11”) Result: 4938.7520 mi RE: (20S and 21S) Great Circle - Marcel - 06-03-2017 10:00 PM Hi Eddie! For an other planet, the user must change the numerical factor!!!.. the radius of the planet in miles or km. Marcel RE: (20S and 21S) Great Circle - Dieter - 06-04-2017 03:37 PM (06-03-2017 10:00 PM)Marcel Wrote: For an other planet, the user must change the numerical factor!!!.. the radius of the planet in miles or km. Since most planets are not perfect spheres there is not a single radius. For instance the WGS84 system (cf. GPS) works with an Earth radius of 6378,137 km in East-West direction and with 6356,7523 km for North-South. Eddie's formula uses a constant radius of 3958,75 miles or 6371 km. This is a good choice that minimizes the error of the calculation (cf. here). Yet there still is a potential error of 0,5%. So the result should be rounded to at most three significant digits. For the given examples that's 6320 resp. 4940 miles. A final hint: enter an angle, and 1 P→R simultaneously returns both sine (in Y) and cosine (in X). Edit: this works on classic RPN calculators and probably cannot be used for the algebraic 20S and 21S. Dieter |