希望使用用户指定的点生成圆的一组完整整数坐标,使用圆的公式:(xa)^2 + (yb)^2 = r^2
我怎样才能在 3d 空间中做到这一点,找到 x、y 和 z 的坐标。
不要使用方程的笛卡尔格式,使用参数 one
\n\n而不是 (xa)^2 + (yb)^2 = r^2,你有
\n\nx = r * cos(t) + a
\n\ny = r * sin(t) + b
\n\nt,或更常见的三角函数 \xce\xb8,是 0 和 2\xcf\x80 之间的角度
\n\nimport math\n\na = 2\nb = 3\nr = 3\n\n#The lower this value the higher quality the circle is with more points generated\nstepSize = 0.1\n\n#Generated vertices\npositions = []\n\nt = 0\nwhile t < 2 * math.pi:\n positions.append((r * math.cos(t) + a, r * math.sin(t) + b))\n t += stepSize\n\nprint(positions)\n
Run Code Online (Sandbox Code Playgroud)\n\n由于这是一个二维表面,因此需要第二个参数,因为一个参数是不够的
\n\nu = [0, 2\xcf\x80]\nv = [-\xcf\x80/2, \xcf\x80/2]
\n\nx = r * sin(u) * cos(v) + a
\n\ny = r * cos(u) * cos(v) + b
\n\nz = r * sin(v) + c
\n\nimport math\n\na = 2\nb = 3\nc = 7\nr = 3\n\n#The lower this value the higher quality the circle is with more points generated\nstepSize = 0.1\n\n#Generated vertices\npositions = []\n\nu = 0\nv = -math.pi/2\nwhile u < 2 * math.pi:\n while v < math.pi/2:\n positions.append((r * math.sin(u) * math.cos(v) + a, r * math.cos(u) * math.cos(v) + b, r * math.sin(v) + c))\n v += stepSize\n u += stepSize\n\nprint(positions)\n
Run Code Online (Sandbox Code Playgroud)\n