def shape_ratio(self, shape, ratio):
"""Calculate shape ratio as defined in paper"""
if shape == 1: # spherical
result = 0.2 + 0.8 * sin(pi * ratio)
elif shape == 2: # hemispherical
result = 0.2 + 0.8 * sin(0.5 * pi * ratio)
elif shape == 3: # cylindrical
result = 1.0
elif shape == 4: # tapered cylindrical
result = 0.5 + 0.5 * ratio
elif shape == 5: # flame
if ratio <= 0.7:
result = ratio / 0.7
else:
result = (1.0 - ratio) / 0.3
elif shape == 6: # inverse conical
result = 1.0 - 0.8 * ratio
elif shape == 7: # tend flame
if ratio <= 0.7:
result = 0.5 + 0.5 * ratio / 0.7
else:
result = 0.5 + 0.5 * (1.0 - ratio) / 0.3
elif shape == 8: # envelope
if ratio < 0 or ratio > 1:
result = 0.0
elif ratio < 1 - self.param.prune_width_peak:
result = pow(ratio / (1 - self.param.prune_width_peak),
self.param.prune_power_high)
else:
result = pow((1 - ratio) / (1 - self.param.prune_width_peak),
self.param.prune_power_low)
else: # conical (0)
result = 0.2 + 0.8 * ratio
return result
评论列表
文章目录