如何从三个点计算的角度θ [英] How to calculate an angle from three points?
问题描述
可以说,你有这样的:
P1 = (x=2, y=50)
P2 = (x=9, y=40)
P3 = (x=5, y=20)
假设 P1
是一个圆的中心点。它始终是相同的。
我想这是由由 P2
和 P3
,或者换句话说,就是旁边的<角角code> P1 。内角被precise。它将永远是锐角,所以小于-90度
Assume that P1
is the center point of a circle. It is always the same.
I want the angle that is made up by P2
and P3
, or in other words the angle that is next to P1
. The inner angle to be precise. It will always be an acute angle, so less than -90 degrees.
我想:人,这是简单的几何运算。但我已经找了现在的约6小时,配方,只有找人谈论复杂NASA这样的东西ARCCOS和向量数量积的东西。我的头感觉就像是在冰箱中。
I thought: Man, that's simple geometry math. But I have looked for a formula for around 6 hours now, and only find people talking about complicated NASA stuff like arccos and vector scalar product stuff. My head feels like it's in a fridge.
一些数学大师在这里,觉得这是一个简单的问题?我不认为这里的编程语言重要,但对于那些谁认为它:JAVA和Objective-C。我需要两个,但没有它标记为这些。
Some math gurus here that think this is a simple problem? I don't think the programming language matters here, but for those who think it does: java and objective-c. I need it for both, but haven't tagged it for these.
推荐答案
如果你指的是角度P1是那么这应该工作的顶点:
If you mean the angle that P1 is the vertex of then this should work:
阿尔科斯 ((P 12 2 + P 13 2 - P 23 2 )/(2 * P 12 * P 13 ))
arcos((P122 + P132 - P232) / (2 * P12 * P13))
其中,P 12 是从P1段P2,由
where P12 is the length of the segment from P1 to P2, calculated by
开方((P1 <子> X - P2 <子> X ) 2 + (P1 <子>是 - P2 <子>是) 2 )
sqrt((P1x - P2x)2 + (P1y - P2y)2)
这篇关于如何从三个点计算的角度θ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!