<s> from __future__ import division <EOL> from visual import * <EOL> bands = zeros ( [ <NUM_LIT:16> , <NUM_LIT:16> , <NUM_LIT:4> ] , float ) <EOL> for i in range ( len ( bands ) ) : <EOL> for j in range ( len ( bands [ <NUM_LIT:0> ] ) ) : <EOL> op = <NUM_LIT:1> <EOL> if i % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> op = <NUM_LIT> <EOL> col = color . cyan <EOL> else : <EOL> col = [ color . blue , color . green , color . red , <EOL> color . yellow , color . cyan ] [ i // <NUM_LIT:2> % <NUM_LIT:5> ] <EOL> bands [ i ] [ j ] = ( col [ <NUM_LIT:0> ] , col [ <NUM_LIT:1> ] , col [ <NUM_LIT:2> ] , op ) <EOL> stripes = materials . texture ( data = bands , <EOL> mapping = "<STR_LIT>" , <EOL> interpolate = False ) <EOL> scene . width = scene . height = <NUM_LIT> <EOL> scene . forward = ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT:1> ) <EOL> width = <NUM_LIT:10> <EOL> thick = <NUM_LIT:0.5> <EOL> depth = <NUM_LIT:7> <EOL> height = <NUM_LIT:2> <EOL> xhit = height - thick <EOL> R = <NUM_LIT:2> <EOL> H = <NUM_LIT:10> <EOL> L = <NUM_LIT:5> <EOL> floor = box ( pos = ( <NUM_LIT:0> , - thick / <NUM_LIT:2> , <NUM_LIT:0> ) , size = ( width , thick , depth ) , <EOL> shininess = <NUM_LIT:0> , color = color . orange , material = materials . wood ) <EOL> left = box ( pos = ( - ( width / <NUM_LIT:2> + thick / <NUM_LIT:2> ) , height / <NUM_LIT:2> - thick , <NUM_LIT:0> ) , size = ( thick , height , depth ) , <EOL> shininess = <NUM_LIT:0> , color = color . orange , material = materials . wood ) <EOL> right = box ( pos = ( width / <NUM_LIT:2> + thick / <NUM_LIT:2> , height / <NUM_LIT:2> - thick , <NUM_LIT:0> ) , size = ( thick , height , depth ) , <EOL> shininess = <NUM_LIT:0> , color = color . orange , material = materials . wood ) <EOL> back = box ( pos = ( <NUM_LIT:0> , height / <NUM_LIT:2> - thick , - ( depth / <NUM_LIT:2> + thick / <NUM_LIT:2> ) ) , size = ( width + <NUM_LIT:2> * thick , height , thick ) , <EOL> shininess = <NUM_LIT:0> , color = color . orange , material = materials . wood ) <EOL> ceiling = box ( pos = ( <NUM_LIT:0> , H + thick / <NUM_LIT:2> , <NUM_LIT:0> ) , size = ( width / <NUM_LIT:10> , thick , width / <NUM_LIT:10> ) , color = color . orange , material = materials . wood ) <EOL> pendulum = frame ( pos = ( <NUM_LIT:0> , H , <NUM_LIT:0> ) , axis = ( <NUM_LIT:0> , - <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> wire = curve ( frame = pendulum , pos = [ ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) , ( L , <NUM_LIT:0> , <NUM_LIT:0> ) ] ) <EOL> lamp = sphere ( frame = pendulum , pos = ( L , <NUM_LIT:0> , <NUM_LIT:0> ) , radius = <NUM_LIT> * L , color = color . white , material = materials . emissive ) <EOL> sphere ( pos = ( <NUM_LIT:0.1> * width , R / <NUM_LIT:4> , <NUM_LIT> * depth ) , radius = R / <NUM_LIT:4> , color = color . red , material = materials . marble ) <EOL> sphere ( pos = ( <NUM_LIT> * width , R / <NUM_LIT:4> , <NUM_LIT> * depth ) , radius = R / <NUM_LIT:4> , color = color . yellow , material = materials . marble ) <EOL> sphere ( pos = ( <NUM_LIT> * width , R / <NUM_LIT:4> , - <NUM_LIT> * depth ) , radius = R / <NUM_LIT:4> , color = color . green , material = materials . marble ) <EOL> sphere ( pos = ( <NUM_LIT:0.1> * width , R / <NUM_LIT:4> , - <NUM_LIT> * depth ) , radius = R / <NUM_LIT:4> , color = color . cyan , material = materials . marble ) <EOL> scene . lights = [ ] <EOL> scene . ambient = color . gray ( <NUM_LIT> ) <EOL> l1 = distant_light ( direction = ( <NUM_LIT:6> , <NUM_LIT:2> , <NUM_LIT:4> ) , color = color . gray ( <NUM_LIT> ) ) <EOL> l2 = distant_light ( direction = ( - <NUM_LIT:10> , <NUM_LIT:2> , <NUM_LIT:4> ) , color = color . gray ( <NUM_LIT> ) ) <EOL> lamplight = local_light ( frame = pendulum , pos = ( L , <NUM_LIT:0> , <NUM_LIT:0> ) , color = color . gray ( <NUM_LIT:0.5> ) ) <EOL> scene . center = ( <NUM_LIT:0> , <NUM_LIT> * H , <NUM_LIT:0> ) <EOL> ball = sphere ( pos = ( width / <NUM_LIT:4> , R , <NUM_LIT:0> ) , radius = R , up = ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ) , material = stripes ) <EOL> xlimit = <NUM_LIT:0.5> * width - R * sin ( acos ( <NUM_LIT:1> - ( height - thick ) / R ) ) <EOL> v = vector ( - <NUM_LIT:0.5> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> dt = <NUM_LIT> <EOL> t = <NUM_LIT:0> <EOL> while True : <EOL> rate ( <NUM_LIT:100> ) <EOL> ball . pos += v * dt <EOL> ball . rotate ( axis = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) , angle = - v . x * dt / R ) <EOL> if abs ( ball . x ) >= xlimit : <EOL> v = - v <EOL> angle = <NUM_LIT> * cos ( t ) <EOL> pendulum . rotate ( axis = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , angle = angle ) <EOL> t += dt </s>
