C# 在圆的边缘找到坐标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2093405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding the coordinates on the edge of a circle
提问by Ian Vink
Using C#:
使用 C#:
How do I get the (x, y) coordinates on the edge of a circle for any given degree, if I have the center coordinates and the radius?
如果我有中心坐标和半径,如何获得任何给定度数的圆边缘上的 (x, y) 坐标?
There is probably SIN, TAN, COSIN and other grade ten math involved... :)
可能涉及到 SIN、TAN、COSIN 和其他十年级数学...... :)
采纳答案by David M
This has nothing to do with C#. There is just some elementary mathematics involved.
这与 C# 无关。只涉及一些初等数学。
x = x0 + r * cos(theta)
y = y0 + r * sin(theta)
theta is in radians, x0 and y0 are the coordinates of the centre, r is the radius, and the angle is measured anticlockwise from the x-axis. But if you want it in C#, and your angle is in degrees:
theta 以弧度为单位,x0 和 y0 是中心坐标,r 是半径,角度是从 x 轴逆时针测量的。但是如果你想在 C# 中使用它,并且你的角度是度数:
double x = x0 + r * Math.Cos(theta * Math.PI / 180);
double y = y0 + r * Math.Sin(theta * Math.PI / 180);
回答by Daniel Vassallo
For a circle with origin (j, k)
, radius r
, and angle t
in radians:
对于原点(j, k)
、半径r
和角度t
以弧度表示的圆:
x(t) = r * cos(t) + j
y(t) = r * sin(t) + k
回答by Alastair Pitts
using Pythagoras Theorem (where x1,y1 is the edge point):
使用毕达哥拉斯定理(其中 x1,y1 是边缘点):
x1 = x + rcos(theta)
y1 = y + rsin(theta)
x1 = x + r cos(theta)
y1 = y + rsin(theta)
in C#, this would look like:
在 C# 中,这看起来像:
x1 = x + radius * Math.Cos(angle * (Math.PI / 180));
y1 = y + radius * Math.Sin(angle * (Math.PI / 180));
where all variables are doubles
and angle
is in degrees
其中所有的变量都doubles
和angle
为度