计算直线和x轴之间的角度 [英] calculate the angle between a line and x-axis

查看:710
本文介绍了计算直线和x轴之间的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的坐标系(x,y)中有两个点,我想知道它们的线和x轴的角度.

I have two points in my coordinate system (x,y) that I want to know the angle of their line and x-axis.

我用swift解决了这个问题,但是我没把握角度.

I use swift for solving this but I can't get the angle.

我需要此弧度角以在以下公式中使用它:

I need this angle in radians to use it in the following equation:

(x0 + r cos theta, y0 + r sin theta)

r:圆半径

推荐答案

如果您有两个点(x0, y0)(x1, y1),则连接它们的线的角度(相对于X轴)为:

If you have two points, (x0, y0) and (x1, y1), then the angle of the line joining them (relative to the X axis) is given by:

theta = atan2((y1 - y0), (x1 - x0))

这篇关于计算直线和x轴之间的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆