const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); function sgn(n) { if (n > 0) { return 1; } else if (n < 0) { return -1; } else { return 0; } } function fndeg(d, m, s) { return d + sgn(d) * (m / 60 + s/ 3600); } function fnacs(x) { return Math.PI / 2 - 2 * Math.atan(x / (1 + Math.sqrt(1 - x * x))); } function calc(tlongd, tlatd, rlongd, rlatd) { let ro = 6370; let gcdkm; let btrd; let brtd; let r2d = 180 / Math.PI; let d2r = Math.PI / 180; let tlong = tlongd * d2r; let tlat = tlatd * d2r; let rlong = rlongd * d2r; let rlat = rlatd * d2r; if (tlong < 0) { tlong = Math.PI * 2 + tlong; } if (rlong < 0) { rlong = Math.PI * 2 + rlong; } let dlong = tlong - rlong; if (Math.abs(dlong) > Math.PI) { dlong = dlong - Math.PI * 2 * sgn(dlong); } let x = Math.sin(tlat) * Math.sin(rlat) + Math.cos(tlat) * Math.cos(rlat) * Math.cos(dlong); let gcd = fnacs(x); if (gcd < 0.0000001) { gcd = 0.0000001; } if (Math.cos(tlat) - 0.0000001 <= 0) { let btr; if (tlat >= 0) { btr = 0; } else { btr = Math.PI; } if (Math.cos(rlat) - 0.0000001 > 0) { x = (Math.sin(tlat) - Math.sin(rlat) * Math.cos(gcd)) / (Math.cos(rlat) * Math.sin(gcd)); let brt = fnacs(x); if (dlong < 0) { brt = Math.PI * 2 - brt; } gcdkm = gcd * ro; btrd = btr * r2d; brtd = brt * r2d; } else { let brt; if (rlat >= 0) { brt = 0; } else { brt = Math.PI; } gcdkm = gcd * ro; btrd = btr * r2d; brtd = brt * r2d; } } else { x = (Math.sin(rlat) - Math.sin(tlat) * Math.cos(gcd)) / (Math.cos(tlat) * Math.sin(gcd)); let btr = fnacs(x); if (dlong > 0) { btr = Math.PI * 2 - btr; } if (Math.cos(rlat) - 0.0000001 > 0) { x = (Math.sin(tlat) - Math.sin(rlat) * Math.cos(gcd)) / (Math.cos(rlat) * Math.sin(gcd)); let brt = fnacs(x); if (dlong < 0) { brt = Math.PI * 2 - brt; } gcdkm = gcd * ro; btrd = btr * r2d; brtd = brt * r2d; } else { let brt; if (rlat >= 0) { brt = 0; } else { brt = Math.PI; } gcdkm = gcd * ro; btrd = btr * r2d; brtd = brt * r2d; } } return [gcdkm, btrd, brtd]; } function main() { console.log("《计算通信方位角和大圆距离程序》") let gcdkm; let btrd; let brtd; rl.question("发信点经度(度,分,秒)=", function(tmp) { tmp = tmp.toString().split(",") let tmp2 = []; for (let i=0;i