Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | /** * @description 返回当前两点连成的线与Y轴的夹角 * @author SoldierAb * @param {Number} 起始坐标x1,y1 当前坐标x2,y2 * @returns {Object} * @example * · * · ^ y * (x1,y1) * | * · | * · | * · | * · | * (x2,y2) * | * · | * -----------------------·--------------------------> * ·| O x * | * |· * | * | * | * | * | * | * * * * */ export default (x1, y1, x2, y2) => { // 直角的边长 let x = Math.abs(x1 - x2); let y = Math.abs(y1 - y2); // 斜边长 let z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); // 余弦 let cos = y / z; // 弧度 let radina = Math.acos(cos); // 角度 let angle = 180 / (Math.PI / radina); return { angle: angle, xdis: x2 - x1, ydis: y2 - y1 }; } |