【问题标题】:How calc angle of sectors by two points, radius, center of circle如何通过两点、半径、圆心计算扇区的角度
【发布时间】:2016-07-26 21:48:25
【问题描述】:

如何通过两点、半径、圆心来计算扇区的角度。 我试试这个:(p1,p2 - 圆中的点,中心 - 圆的中心)

startAngle = (int)(180 / Mathf.PI * Mathf.Atan2(p1.y - center.y, p1.x - center.x));
endAngle = (int)(180 / Mathf.PI * Mathf.Atan2(p2.y - center.y, p2.x - center.x));

【问题讨论】:

    标签: math geometry sector


    【解决方案1】:

    假设你想测量绕 x 轴逆时针方向的角度,我觉得你的东西不错。

    Here it is in Latex,下标零数量为圆心。

    【讨论】:

      【解决方案2】:

      您可以使用叉积和标量积求向量到第一个点和第二个点之间的角度。这种方法给出了有符号(有向)角。

      dy1 = p1.y - center.y;
      dx1 = p1.x - center.x;
      dy2 = p2.y - center.y;
      dx2 = p2.x - center.x;
      SectorAngle = Mathf.Atan2(dx1*dy2-dx2*dy1, dx1*dx2+dy1*dy2)
      

      【讨论】:

        猜你喜欢
        • 2010-09-16
        • 1970-01-01
        • 1970-01-01
        • 2014-05-12
        • 1970-01-01
        • 2019-06-18
        • 2021-04-09
        • 1970-01-01
        • 2021-11-09
        相关资源
        最近更新 更多