我想将下面代码中的x和y坐标提取出来,放到excel中,应该怎么做呢
class BIRD(object):
def init(self, x, y, theta, v0):
self.x = x
self.y = y
self.theta = theta
self.v = v0
self.old_theta = theta
def move(self, dt, worldlimit):
self.x += self.v * math.cos(self.theta) * dt
self.y += self.v * math.sin(self.theta) * dt
self.x = self.x % worldlimit
self.y = self.y % worldlimit
def align_i(brids, i, Rsquare):
x = birds[i].x
y = birds[i].y
neighbors = []
for j in range(len(birds)):
if j != i:
if (birds[j].x - x)**2 + (birds[j].y - y)**2 <= Rsquare:
neighbors.append(j)
if len(neighbors) != 0:
tempx, tempy = 0, 0
for k in neighbors:
tempy += math.sin(birds[k].old_theta)
tempx += math.cos(birds[k].old_theta)
birds[i].old_theta = birds[i].theta
if tempx < 0:
birds[i].theta = math.atan(tempy/tempx) + math.pi
else:
birds[i].theta = math.atan(tempy/tempx)
这样粘贴的代码可读性比较差,你可以把代码都粘贴到代码块中,编辑器的这个图标</>