Performance 1, Draft 1

work.title = "Performance 1, Draft 1"
scene.gravity = Earth.g0
scene.air = None



## Show the origin, with a 1m line for each axis

# 10cm cube at the origin
origin_indicator = Cube(size=0.1 m, color=Magenta(0.75))

# (R,G,B) for (+X, +Y, +Z)
plus_x = Box(width= 100 cm, height=  10 cm, depth=  10 cm, translation= Point(50 cm,  0 cm,  0 cm), color=Red(1))
plus_y = Box(width=  10 cm, height= 100 cm, depth=  10 cm, translation= Point( 0 cm, 50 cm,  0 cm), color=Green(1))
plus_z = Box(width=  10 cm, height=  10 cm, depth= 100 cm, translation= Point( 0 cm,  0 cm, 50 cm), color=Blue(1))



## Create the floor (a flat cement foundation, with a moated octagon in the middle)

# Params
num_sides = 8
floorplan_footprint = Rect(width= 20 m, height= 20 m)
pattern_box_radius_from_origin = 5 m
foundation_octagon_wall_midpoint_dist_from_origin = pattern_box_radius_from_origin + 0.5 m
foundation_octagon_corner_radius = foundation_octagon_wall_midpoint_dist_from_origin / cos(0.5/8 turn)
island_octagon_corner_radius = foundation_octagon_corner_radius - 1 m
foundation_thickness = 1 m
octagon = RegularPolygon(num_sides=num_sides, radius=foundation_octagon_corner_radius, flat_ceiling=True)

# Cement foundation (minus the island and its moat)
foundation = PolygonMesh.via_extrusion(
    face=(floorplan_footprint - octagon),
    depth=foundation_thickness,
    color=Gray(0.5)
)
foundation.rotation = Rotation(rx=90°)
foundation.translation = Point(0 m, 0 m, foundation_thickness/2) # TODO : revisit the order of xforms, etc -- and have this be dy not -dz

# The island
island = PolygonMesh.via_extrusion(
    face=RegularPolygon(num_sides=num_sides, radius=island_octagon_corner_radius, flat_ceiling=True),
    depth=foundation_thickness,
    color=Gray(0.5)
)
island.rotation = Rotation(rx=90°)
island.translation = Point(0 m, 0 m, foundation_thickness/2)# TODO : revisit the order of xforms, etc -- and have this be dy not -dz



## Create the performers

performers = []
for i in range(num_sides):
    xz_heading = Angle(i / num_sides, "turn")
    pattern_box_height = 100 cm

    pattern_box = Box(
        width=   70 cm,
        height= 100 cm,
        depth=    2 cm,
        rotation= Rotation(ry=xz_heading),
    )
    tr_base = Point(y=0, xz_heading=xz_heading, radius=pattern_box_radius_from_origin)
    pattern_box.translation=tr_base.but_with_y(pattern_box_height/2 - 0.5 m)

    p = Juggling.Performer(
        pattern_box= pattern_box,
        core_box= None,
        inner_outer_spread= 20 cm,
        inner_outer_tilt= 0,
    )

    r = Sphere(diameter=9 cm, color=Red(0.6))
    g = Sphere(diameter=9 cm, color=Green(0.6))
    b = Sphere(diameter=9 cm, color=Blue(0.6))
    p.props = [r, g, b]

    performers.append(p)


## Define the tosses

for p in performers:

    # 5 reps of a 2-second loop
    for rep in range(5):
        t = Time(2 * rep, "s")

        r, g, b = p.props

        # red prop
        t0 = t + (0 + 0/3) s;  p.toss(r, dt=0.75 s, t0=t0, src=p.right_inner, dest=p.left_outer)
        t0 = t + (1 + 0/3) s;  p.toss(r, dt=0.75 s, t0=t0, src=p.left_inner, dest=p.right_outer)

        # green prop
        t0 = t + (0 + 1/3) s;  p.toss(g, dt=0.75 s, t0=t0, src=p.left_inner, dest=p.right_outer)
        t0 = t + (1 + 1/3) s;  p.toss(g, dt=0.75 s, t0=t0, src=p.right_inner, dest=p.left_outer)

        # blue prop
        t0 = t + (0 + 2/3) s;  p.toss(b, dt=0.75 s, t0=t0, src=p.right_inner, dest=p.left_outer)
        t0 = t + (1 + 2/3) s;  p.toss(b, dt=0.75 s, t0=t0, src=p.left_inner, dest=p.right_outer)