这似乎做什么我期待。
进口数学
高清的main(): getTickGap(-1,1.5)
高清next_multiple(X,Y): 回报math.ceil(X/Y)* Y
DEF getTickGap(XMIN,XMAX): xdelta = XMAX -xmin 宽度= 250 #最小的10大于δ 因子= 10 ** math.ceil(math.log(xdelta,10)) #0.1更大的功率< =正常化d_delta normalised_delta = xdelta /因子 打印( “normalised_delta”,normalised_delta)
# we want largest gap
if normalised_delta/4 >= 0.1:
step_size = 0.1
elif normalised_delta/4 >= 0.05:
step_size = 0.05
elif normalised_delta/20 <= 0.01:
step_size = 0.01
step_size = step_size * factor
## if normalised_delta/20 == 0.005:
## step_size = 0.005
## elif normalised_delta/20 <= 0.01:
## step_size = 0.01
## elif normalised_delta/4 >= 0.05:
## step_size = 0.05
## step_size = step_size * factor
print("step_size", step_size)
totalsteps = xdelta/step_size
print("Total steps", totalsteps)
print("Range [", xmin, ",", xmax, "]")
firstInc = next_multiple(xmin, step_size)
count = (250/xdelta)*(firstInc - xmin)
print("firstInc ", firstInc, 'tick at ', count)
print("start at ", firstInc - xmin, (width/totalsteps)*(firstInc - xmin))
inc = firstInc
while (inc <xmax):
inc += step_size
count += (width/totalsteps)
print(" inc", inc, "tick at ", count)
如果名称 == “主”: 主()
谢谢!因子= 10 ** math.ceil(math.log(delta,10))做了tric! – coulix 2008-12-07 09:36:48