确定圆上两点之间相对于中心的角度 [英] determine angle between two points on a circle with respect to center

查看:1000
本文介绍了确定圆上两点之间相对于中心的角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个环(宽度25像素)作为UIView.当用户选择圆环上的任意位置时,我要考虑圆心,计算圆上固定点上选定的点之间的角度. 我发现的例子很少,但并未将其考虑在内.

I have a Ring(width 25px) as UIView. When User selects any where on the ring, I want to Calculate the Angle between the the Points Selected on a fixed point on the circle considering the Center of Circle. I have found few examples but they are not taking center into consideration.

执行此操作的最佳方法是什么?

推荐答案

您必须亲自处理代码(我是Java开发人员),但最简单的方法是获取圆上两点之间的角度(相对于其中心进行测量)是回忆情况的几何形状.由圆的圆周上的任意两个点和圆的中心组成的三角形必须是等腰线.

You'll have to handle the code yourself (I'm a Java developer), but the simplest way to get the angle between two points on a circle (measured against its center) is to recall the geometry of the situation. The triangle formed by any two points on the circumference of a circle and the circle's center is necessarily isosceles.

回想起来,等腰三角形的(至少)两个边的长度相同-指向您两点的径向线段.将角度二等分会导致一个径向段,该径向段垂直于并平分连接这两个点的线.这形成一对直角三角形,半径为斜边,两点之间的距离的一半为相对"边.

An isosceles triangle, recall, has (at least) two sides of the same length -- the radial segments to your two points. Bisecting the angle results in a radial segment which is perpendicular to and bisects the line connecting the two points. This forms a pair of right triangles, with the radius as the hypotenuse, and half the distance between the two points as the 'opposite' side.

将分母乘以2并识别出半径是半径的两倍,只需计算两点之间的距离(在圆周上),然后将其除以直径即可.您获得的值是半角的正弦(您需要整个角).拿反正弦,你将有一半的角度:

Moving the factor of two to the denominator and recognizing what twice the radius is, simply calculate the distance between the two points (on the circumference), and divide it by the diameter. The value you get is the sine of the half-angle (you desire the whole angle). Take the arcsine, and you'll have half your angle:

θ/2 = sin -1 (d/D)

θ/2 = sin-1(d/D)

d作为两点之间的距离,以D作为圆的直径.由于给出了直径,因此两点之间的距离为计算简单 ,到达这一点应该很容易,然后只需将计算出的值加倍即可获得两点之间的整个角度.

With d as the distance between the two points, and D as the diameter of the circle. Since the diameter is given, and the distance between the two points is simple to calculate, getting to this point should be easy, and then you just need to double the value calculated to get the whole angle between the two points.

这篇关于确定圆上两点之间相对于中心的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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