Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,29 @@
class EarthPoint(lat, lon) {
const earth_radius = 6371; # mean earth radius
const radian_ratio = Math.pi/180;
# accessors for radians
method latR { self.lat * radian_ratio };
method lonR { self.lon * radian_ratio };
method haversine_dist(EarthPoint p) {
var arc = EarthPoint(
self.lat - p.lat,
self.lon - p.lon,
);
var a = Math.sum(
(arc.latR / 2).sin**2,
(arc.lonR / 2).sin**2 *
self.latR.cos * p.latR.cos
)
earth_radius * a.sqrt.asin * 2;
}
}
var BNA = EarthPoint.new(lat: 36.12, lon: -86.67);
var LAX = EarthPoint.new(lat: 33.94, lon: -118.4);
say BNA.haversine_dist(LAX); # => 2886.44444283798329974715782394574672