def spiro(num_teeth_fixed, num_teeth_move, height, num_segs, outfile):
N = abs(num_teeth_fixed)
D = abs(num_teeth_move)
side_sign = num_teeth_move/D
height = height*D/N
num_segs = num_segs
turns = D/fractions.gcd(N, D)
print('OFF\n{} 1 0'.format(num_segs), file=outfile)
for i in range(num_segs):
ang_fixed = 2*math.pi*turns*i/num_segs
ang_move = side_sign * ang_fixed * N/D
move_cent = [math.cos(ang_fixed)*(N + side_sign*D)/N,
math.sin(ang_fixed)*(N + side_sign*D)/N, 0]
move_offset = [height*math.cos(ang_fixed+ang_move),
height*math.sin(ang_fixed+ang_move), 0]
P = [move_cent[i] + move_offset[i] for i in range(3)]
print(P[0], P[1], P[2], file=outfile)
print(num_segs, *[i for i in range(num_segs)], file=outfile)
评论列表
文章目录