两条线之间的角度从同一点开始 [英] Angle between two line start at the same point

查看:242
本文介绍了两条线之间的角度从同一点开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我是二维平面上的任意两点(p1(x1,y1),p2(x2,y1)),并且这两个点与中心(c(c1,c2))形成一条直线。因此,我是两条线在同一点结束。我想知道如何计算这两条线之间的角度。我希望能够显示0-2pi的角度范围。还有0 - ( - 2pi),它让p1和c形成的行成为第1行和其他第2行。
我通过使用atan2()有一些想法,但没有像我想要的那样工作。
谢谢

解决方案

将点转换为矢量(从每个端点减去中心点)并使用点积来计算角度。


Lets say I am any two points on 2d plane (p1(x1,y1), p2(x2,y1)) and both points forms a line with the center(c(c1,c2)). Therefore I am two lines end at same point. I want to know how can I calculate angle between those two lines. I want to be able to show angle range from 0-2pi. Also 0-(-2pi) which let the line form by p1 and c to be line 1 and other line 2. I do have some idea by using atan2() but did not work out like I want it to. Thanks

解决方案

Convert the points to vectors (subtract the center point from each end point) and use the dot product to compute the angle.

这篇关于两条线之间的角度从同一点开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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