[英]Working with vectors, distances and graphs JAVA
I am working with vectors in graphs. 我正在使用图形中的向量。 The first part of the program generates a random position point of a vector on the graph.
程序的第一部分在图形上生成矢量的随机位置点。 Next, I want the program to generate another random position point of a vector on the graph.
接下来,我希望程序在图形上生成向量的另一个随机位置点。 How do I generate the second position vector, keeping in mind that the distance between both position vectors has to be 1?
在记住两个位置矢量之间的距离必须为1的情况下,如何生成第二个位置矢量?
x
between 0 and 360 (or between 0 and 2*PI if you use radians). x
随机化在0到360之间(如果使用弧度,则在0到2 * PI之间)。 cos(x)
to the x-value of the first random position point cos(x)
添加到第一个随机位置点的x值 sin(x)
to the y-value of the first random position point sin(x)
添加到第一个随机位置点的y值 Why? 为什么? Geometry.
几何。 All the points on the circle
(cos(x), sin(x))
are always 1 unit length away from its center. 圆上的所有点
(cos(x), sin(x))
始终与其中心相距1个单位长度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.