예제 #1
0
def make_demo(width=20, ball_radius=5, path_radius=5, steps=30):
    x, y = la.Axis(width, 'x'), la.Axis(width, 'y')
    t = la.Axis(steps, 't')
    center = (width - 1) / 2
    ball_center_x = la.sin(la.radians(t * 360 / steps)) * path_radius + center
    ball_center_y = la.cos(la.radians(t * 360 / steps)) * path_radius + center
    return la.maximum(
        ball_radius - la.sqrt((x - ball_center_x)**2 + (y - ball_center_y)**2),
        0).transpose(x, y)
예제 #2
0
def make_sphere(width=20, radius=9):
    x, y, z = la.Axis(width, 'x'), la.Axis(width, 'y'), la.Axis(width, 'z')
    center = (width - 1) / 2
    return la.maximum(
        radius - la.sqrt((x - center)**2 + (y - center)**2 + (z - center)**2),
        0)