如何从三点计算角度? [英] How to calculate an angle from three points?

查看:36
本文介绍了如何从三点计算角度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有这个:

P1 = (x=2, y=50)
P2 = (x=9, y=40)
P3 = (x=5, y=20)

假设 P1 是圆的中心点.它总是一样的.我想要由 P2P3 组成的角度,或者换句话说,P1 旁边的角度.内角要精确.它总是一个锐角,所以小于 -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 using the Law of Cosines should work:

arccos((P122+ P132 - P232)/(2 *P12 * P13))

arccos((P122 + P132 - P232) / (2 * P12 * P13))

其中 P12 是从 P1 到 P2 的段的长度,计算公式为

where P12 is the length of the segment from P1 to P2, calculated by

sqrt((P1x -P2x)2 +(P1y -P2y)2)

sqrt((P1x - P2x)2 + (P1y - P2y)2)

这篇关于如何从三点计算角度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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