为什么这个方程可以用来找到圆周上n个等距点?

huangapple go评论75阅读模式
英文:

Why does this equation work for finding n equidistant points around a circle?

问题

对于一个问题,我们需要在圆周上均匀地绘制n个点。我不知道如何做到这一点,所以我查找了一下并找到了一个解决方案,但我不知道为什么它有效。下面是我为每个点使用的方程式。

StdDraw.point(Math.cos((i * 2 * Math.PI) / n) + 1, Math.sin((i * 2 * Math.PI) / n) + 1); 

这个代码块被放置在一个for循环中,所以“i”是点的序号,“n”是需要绘制的点的数量。我在末尾加了1,以便将其转换为适应画布范围内。

有人知道它为什么有效吗?

英文:

For a problem, we have to graph n equidistant points around a circle. I didn't know how to do that, so I searched it up and found a solution, but I don't know why it works. Here is the equations I used for each point.

StdDraw.point(Math.cos((i * 2 * Math.PI) / n) + 1, Math.sin((i * 2 * Math.PI) / n) + 1); 

This was put in a for loop, so "i" is what number point it is and "n" is the number of points that need to be graphed. I added 1 at the end to translate it to fit inside the canvas.

Does anyone know why it works?

答案1

得分: 1

正弦和余弦输出曲线模拟了圆周上的所有点,并通过输入圆内存在的所有可能角度来实现这一点,即如果使用弧度,则为2pi。现在,如果你将2pi*(i/n)输入正弦和余弦函数,这就相当于在0到2*pi之间为每个函数提供了n个角度,输出结果是均匀分布的,因为你输入了均匀分布的角度,所以你将得到在你输入的这些角度末端的等距离点。

观看正弦和余弦在圆周上的动图,然后观察正弦和余弦的图表,一切将变得更加清晰。

英文:

Sine and Cosine output curves model all of the points along the circumference of a circle and they do this by being fed all of the possible angles that exist within a circle i.e 2pi if you use radians. Now, if you feed 2pi*(i/n) to sine and cosine that is giving each respective function n angles between 0 and 2*pi, and the output each spits out is then equidistant because you fed in equidistant angles, so you will receive equidistant points that fall at the ends of those angles that you fed in.

Look at a gif of sine and cosine around a circle, then a graph of sine and cosine and more will make sense.

huangapple
  • 本文由 发表于 2020年10月8日 01:33:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/64249367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定