Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun great-circle-distance (from-longitude from-latitude to-longitude to-latitude)
- (let ((Earth-radius 6371))
- (* 2
- Earth-radius
- (asin (min (sqrt (* (expt (sin (/ (- to-latitude from-latitude ) 2)) 2)
- (expt (sin (/ (- to-longitude from-longitude) 2)) 2)
- (cos to-latitude)))
- 1)))))
- (defun transport-time (distance)
- (flet ((format-and-print (divisor transport-method)
- (format NIL "Human terms: ~a away by ~a, using an average speed of ~a km/h."
- (/ distance divisor) transport-method divisor)))
- (cond
- ((< distance 0))
- ((< distance 150)
- (format-and-print 50 "car"))
- ((< distance 2500)
- (format-and-print 130 "train"))
- ((< distance 12500)
- (format-and-print 800 "plane"))
- (T
- (format-and-print 18000 "ICBM")))))
- (multiple-value-bind (from-latitude from-longitude) (coordinates place1)
- (multiple-value-bind (to-latitude to-longitude) (coordinates place2)
- (let ((distance) (great-circle-distance from-longitude from-latitude to-longitude to-latitude))
- (format NIL "Distance: ~a km" distance)
- (transport-time distance))))
Advertisement
Add Comment
Please, Sign In to add comment