0
私は、PythonコードまたはJavaScriptを使ってらせん線の座標を束ねたいと思います。 このようなものはArchimedean_spiral座標描画のスパイラルを作るにはどうすればいいですか
どのようにすればいいのですか?ここで
私は、PythonコードまたはJavaScriptを使ってらせん線の座標を束ねたいと思います。 このようなものはArchimedean_spiral座標描画のスパイラルを作るにはどうすればいいですか
どのようにすればいいのですか?ここで
あなたは、このサイトはあなたのように幅広い質問をするためであれば、私は知らないが、コーディングの問題として、これは非常に興味深いものだった
import math
# Define variables and create the grid
a = 0
b = 2
rounds = 5
# Size of the grid
y_max, x_max = 100, 100
# Center of the grid
origo_y, origo_x = 50, 50
# Every element in the grid is truly unique element
# If the grid is created like this
# Don't use for example [[" "]*x_max]*y_max
grid = [[" " for i in range(x_max)] for j in range(y_max)]
for angle in range(rounds*360):
# Calculations for the spiral
rads = math.radians(angle)
r = a + b * rads
y = r * math.sin(rads)
x = r * math.cos(rads)
x_coord = origo_x + round(x)
y_coord = origo_y + round(y)
if (0 <= x_coord < x_max) and (0 <= y_coord < y_max):
grid[y_coord][x_coord] = "#"
# Print the whole grid
for line in grid:
print("".join(line))
を行きます。
私はそれを知らなかった。とにかくありがとうございました!! – ehaannnn