Google ClassroomTítulo para compartir en Google Classroom
GeoGebraAula GeoGebra

Mystery curves flying

Check the first version of the script in the applet. The following is an updated version using the command Zip: ##-- Set initial values --## m = 5 Lm = Sequence(m) #Complex numbers and frequencies# Cx = Zip(RandomUniform(-2,2), l, Lm) Cy = Zip(RandomUniform(-2,2), l, Lm) n = Zip(RandomBetween(-30, 30), l, Lm) #Calculate components: C * exp(n * i * x)# cX = Zip(cx * cos(nr * x) - cy * sin(nr * x), cx, Cx, cy, Cy, nr, n) SetVisibleInView(cX, 1, false) cY = Zip(cx * sin(nr * x) + cy * cos(nr * x), cx, Cx, cy, Cy, nr, n) SetVisibleInView(cY, 1, false) #Choose a random number # r = RandomBetween(2, m) #Set the sums of components# fx(x)= Sum(cX, r) fy(x)= Sum(cY, r) SetVisibleInView(fx, 1, false) SetVisibleInView(fy, 1, false) #### #For testing s = Slider(0, 4 pi, pi/2, 1, 150, false, true, false, false) SetValue(s, 4 pi) a = Curve(fx(t), fy(t), t, 0, s) ShowLabel(a, false) SetColor(a, 0.85, 0.85, 0.85) #b = Curve(fx(t), fy(t), t, int + pi, int + val + pi) #c = Curve(fx(t), fy(t), t, int, int + val) #### ##-- Curves --## #Animation setup# speed = Slider(0, 4, 0.01, 1, 150, false, true, false, false) SetValue(speed, 0.55) SetVisibleInView(speed, 1, false) SetVisibleInView(speed, 2, true) int = Slider(0, 2 pi, 0.01, speed, 150, false, true, false, false) SetVisibleInView(int, 1, false) SetVisibleInView(int, 2, true) #Auxiliar values# #Number of sections nb = 10 #Thickness th = 2.5 #Index for curves Lk = Sequence(nb) #Names for curves LnameA= Zip("secA"+Text(n)+"", n, Lk) LnameB= Zip("secB"+Text(n)+"", n, Lk) SetVisibleInView(LnameA, 1, false) SetVisibleInView(LnameB, 1, false) #Slider to set the length of the curve val = Slider(0.01, pi/4, 0.01, 1, 150, false, true, false, false) SetValue(val, RandomUniform(0.06, pi/4)) SetVisibleInView(val, 1, false) SetVisibleInView(val, 2, true) #Plot curves Execute(Zip(""+name+" = Curve( fx(t), fy(t), t, int + pi + ("+k+"-1)* val / nb, int + pi + "+k+" * val / nb )", name, LnameA, k, Lk)) Execute(Zip(""+name+" = Curve( fx(t), fy(t), t, int + ("+k+"-1)* val / nb, int + "+k+" * val / nb )", name, LnameB, k, Lk)) ##-- Settings: Colors and Thickness --## R = random() G = random() B = random() Execute(Zip("ShowLabel("+name+", false)", name, LnameA)) Execute(Zip("SetLineThickness("+name+", th * "+k+")", name, LnameA, k, Lk)) Execute(Zip("SetDynamicColor("+name+", R, G, B)", name,LnameA)) Execute(Zip("ShowLabel("+name+", false)", name, LnameB)) Execute(Zip("SetLineThickness("+name+", th * "+k+")", name, LnameB, k, Lk)) Execute(Zip("SetDynamicColor("+name+", 1-R, 1-G, 1-B)", name,LnameB)) SetBackgroundColor("Black") ShowGrid(false) StartAnimation(int, true) ShowAxes(false)