首页 > 编程知识 正文

两条直线之间的夹角,两个直线的夹角怎么算

时间:2023-05-06 07:44:32 阅读:195600 作者:675


计算上面两直线的夹角,代码如下

const getAngle = ({ x: x1, y: y1 }, { x: x2, y: y2 }) => { const dot = x1 * x2 + y1 * y2 const det = x1 * y2 - y1 * x2 const angle = Math.atan2(det, dot) / Math.PI * 180 return (angle + 360) % 360}const angle = getAngle({ x: x1 - x3, y: y1 - y3,}, { x: x2 - x3, y: y2 - y3,});console.log(angle);

转载于:https://www.cnblogs.com/ystrdy/p/10324466.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。