整點散點積分,備用
往后打算做傅里葉級數(shù)的二位擬合。。numpy,scipy沒弄好,先墊上這些。

import math,turtle
xy = [0,
? ? ? 0,1,
? ? ? 1,1,
? ? ? 2,1,
? ? ? 3,1,
? ? ? 4,1,
? ? ? 5,2,
? ? ? 6,3,
? ? ? 7,4,
? ? ? 8,5,
? ? ? 9,5,
? ? ? 10,4
? ? ? ]#0,x,y,x,y....
a = int(len(xy)/2)
c = 0
turtle.speed(speed=0)
turtle.penup()
turtle.goto(-300,0)
turtle.pendown()
turtle.goto(500,0)
turtle.goto(-500,0)
turtle.goto(-300,0)
turtle.goto(-300,500)
turtle.goto(-300,-500)
turtle.goto(-300,0)
for i in range(1,a):
? ? c = c + (xy[2*i+1]-xy[2*i-1])*(xy[2*i+2]+xy[2*i])/2
? ? turtle.goto(50*xy[2*i+1]-300,50*xy[2*i])
turtle.goto(50*(xy[2*i+1]+1)-300,50*xy[2*i+2])
print(c)
標簽: