Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Haversine-formula/Delphi/haversine-formula.delphi
Normal file
20
Task/Haversine-formula/Delphi/haversine-formula.delphi
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
program HaversineDemo;
|
||||
uses Math;
|
||||
|
||||
function HaversineDist(th1, ph1, th2, ph2:double):double;
|
||||
const diameter = 2 * 6372.8;
|
||||
var dx, dy, dz:double;
|
||||
begin
|
||||
ph1 := degtorad(ph1 - ph2);
|
||||
th1 := degtorad(th1);
|
||||
th2 := degtorad(th2);
|
||||
|
||||
dz := sin(th1) - sin(th2);
|
||||
dx := cos(ph1) * cos(th1) - cos(th2);
|
||||
dy := sin(ph1) * cos(th1);
|
||||
Result := arcsin(sqrt(sqr(dx) + sqr(dy) + sqr(dz)) / 2) * diameter;
|
||||
end;
|
||||
|
||||
begin
|
||||
Writeln('Haversine distance: ', HaversineDist(36.12, -86.67, 33.94, -118.4):7:2, ' km.');
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue