Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一个标识符值,当 lerping 到下一个时它是循环的。例子:
0,1,2,3
当 lerping 从任何 id 到行中的下一个时,我们总是在两个 id 之间得到一个值。除了 3:当 lerping 到下一个 id(回到零)时,它将通过所有 id 进行 lerped。
所以我正在寻找的是两个维度的东西,例如:
(0,0), (0,1), (1,1), (1,0)
当从 (1,0) 学习到 (0,0) 时,它会很好。
如何在函数或循环中扭曲它以将例如 0、1、2、3、4 转换为二维 id?
所以你正在寻找一个函数,它接受一个k从 0 到 N-1 的数字并返回一个圆上的点?这就是三角函数正弦和余弦的定义。
k
您可以将数字k转换为点 (x, y),其中:
x = cos(k*360°/N) y = sin(k*360°/N)
(请注意,大多数软件库以弧度而不是度数输入,如果是这种情况,您可以用 2*pi 替换 360 度,或者使用内置的“toRadians”函数)