在Circle中找到tanget Point

iTu*_*rki 3 java math

给这个草图:

在此输入图像描述

有没有可能找到任何切点(蓝色的)给你知道:

  • 圆的中心点(宽度/ 2,宽度/ 2).
  • 度角连接未知点到中心的线的(角度从计算start angle点在CW方向).

谢谢.

ebo*_*oix 7

是的,这绝对是可能的.

半径是width/2.

你知道角度,三角学也是如此.

这是一些代码:

double radius = width/2;
double x = (radius)*Math.cos(-angle); // angle is in radians
double y = (radius)*Math.sin(-angle);
Run Code Online (Sandbox Code Playgroud)

如果角度是度,您可以将其更改为这样的弧度.

angle = angle/180.0*Math.PI;


编辑

由于您只需要正值,因此您可以使用已经计算过的xy.

x += radius;

y = radius - y;

关于单位圈的视频:http://www.khanacademy.org/math/trigonometry/v/unit-circle-definition-of-trig-functions