n=10[br]Ln = 1..n[br]#---------------------------------------[br]# Position[br]#---------------------------------------[br]Execute(Zip("posx"+k+" = Slider(-20, 20, 0.001, 1, 140, false, true, false, false)", k, Ln))[br]Execute(Zip("posy"+k+" = Slider(-20, 20, 0.001, 1, 140, false, true, false, false)", k, Ln))[br]Execute(Zip("SetVisibleInView(posx"+k+", 1, false)", k, Ln))[br]Execute(Zip("SetVisibleInView(posy"+k+", 1, false)", k, Ln))[br]Execute(Zip("SetValue(posx"+k+", RandomUniform(-15, 15))", k, Ln))[br]Execute(Zip("SetValue(posy"+k+", RandomUniform(-10, 10))", k, Ln))[br][br][br]#---------------------------------------[br]# Velocity[br]#---------------------------------------[br]Execute(Zip("velx"+k+" = Slider(-0.3, 0.3, 0.001, 1, 140, false, true, false, false)", k, Ln))[br]Execute(Zip("vely"+k+" = Slider(-0.3, 0.3, 0.001, 1, 140, false, true, false, false)", k, Ln))[br]Execute(Zip("SetVisibleInView(velx"+k+", 1, false)", k, Ln))[br]Execute(Zip("SetVisibleInView(vely"+k+", 1, false)", k, Ln))[br]Execute(Zip("SetValue(velx"+k+", RandomUniform(-0.3, 0.3))", k, Ln))[br]Execute(Zip("SetValue(vely"+k+", RandomUniform(-0.3, 0.3))", k, Ln))[br][br]#---------------------------------------[br]#Attractor[br]#---------------------------------------[br]Otx=Slider(-15,15, 0.001, 1, 140, false, true, false, false)[br]Oty=Slider(-10,10, 0.001, 1, 140, false, true, false, false)[br]SetValue(Otx, 0)[br]SetValue(Oty, 0)[br]SetVisibleInView(Otx, 1, false)[br]SetVisibleInView(Oty, 1, false)[br][br]A=(Otx, Oty)[br]SetCaption(A, "Drag")[br][br]#---------------------------------------[br]# Direction[br]#---------------------------------------[br]Execute(Zip("dirx"+k+" = Otx - posx"+k+"", k, Ln))[br]Execute(Zip("diry"+k+" = Oty - posy"+k+"", k, Ln))[br]Execute(Zip("norm"+k+" = sqrt( (dirx"+k+")^2 + (diry"+k+")^2 )", k, Ln))[br]Execute(Zip("scalex"+k+" = RandomUniform(0.0005, 0.009)"+k+"", k, Ln))[br]Execute(Zip("scaley"+k+" = RandomUniform(0.0005, 0.009)"+k+"", k, Ln))[br][br]#---------------------------------------[br]# Acceleration[br]#---------------------------------------[br]##normalize and scale##[br]Execute(Zip("accx"+k+"=(Otx - posx"+k+") / norm"+k+" * scalex"+k+"", k, Ln))[br]Execute(Zip("accy"+k+"=(Oty - posy"+k+") / norm"+k+" * scaley"+k+"", k, Ln))[br][br]#---------------------------------------[br]# Stars[br]#---------------------------------------[br]r(α) = 1.5(0.4 + 0.1*sin(5α))[br]SetVisibleInView(r, 1, false)[br]#star = Curve((r(α);α)+(x, y), α, 0, 2pi)[br]Execute(Zip("angle"+k+"=atan2( posy"+k+", posx"+k+" )", k, Ln))[br]Execute(Zip("SetVisibleInView(angle"+k+", 1, false)", k, Ln))[br]Execute(Zip("star"+k+"= Rotate( Curve((r(α);α)+(posx"+k+", posy"+k+"), α, 0, 2pi), angle"+k+", (posx"+k+", posy"+k+") )", k, Ln))[br]Execute(Zip("ShowLabel(star"+k+", false)", k, Ln))[br]Execute(Zip("SetDynamicColor(star"+k+", 255/255, 215/255, 0/255, 1)", k, Ln))[br][br]#---------------------------------------[br]# For animation[br]#---------------------------------------[br]Run=Slider(-5, 5, 0.01, 1, 140, false, true, false, false)[br]ShowLabel(Run, false)[br]SetVisibleInView(Run, 1, false)[br][br]#------------------------------------------------------[br]#After Run is defined add this script in Update[br]#------------------------------------------------------[br]#Execute(Zip("SetValue(velx"+k+", velx"+k+" + accx"+k+" )", k, Ln))[br]#Execute(Zip("SetValue(vely"+k+", vely"+k+" + accy"+k+" )", k, Ln))[br][br]#Execute(Zip("SetValue(posx"+k+", posx"+k+" + velx"+k+" )", k, Ln))[br]#Execute(Zip("SetValue(posy"+k+", posy"+k+" + vely"+k+" )", k, Ln))[br][br]#---------------------------------------[br]#Extra settings[br]#---------------------------------------[br][br]SetBackgroundColor("Black")[br]ShowAxes(false)[br]ShowGrid(false)[br][br]CenterView(A)[br][br]a=false[br]SetCaption(a, "Run")[br]SetValue(a, false)[br]SetColor(a, "White")[br]#------------------------------------------------------[br]#After boolean is defined add this script in Update[br]#------------------------------------------------------[br]#StartAnimation(Run, a)
#---------------------------------------[br]# Position[br]#---------------------------------------[br]n=10[br]Execute(Sequence("A"+i+"=Slider(-20, 20, 0.001, 1, 140, false, true, false, false)", i, 1, n))[br]Execute(Sequence("B"+i+"=Slider(-20, 20, 0.001, 1, 140, false, true, false, false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(A"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(B"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("SetValue(A"+i+", RandomUniform(-15, 15))", i, 1, n))[br]Execute(Sequence("SetValue(B"+i+", RandomUniform(-10, 10))", i, 1, n))[br][br]#---------------------------------------[br]# Velocity[br]#---------------------------------------[br]Execute(Sequence("E"+i+"=Slider(-0.3, 0.3, 0.001, 1, 140, false, true, false, false)", i, 1, n))[br]Execute(Sequence("F"+i+"=Slider(-0.3, 0.3, 0.001, 1, 140, false, true, false, false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(E"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(F"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("SetValue(E"+i+", RandomUniform(-0.3, 0.3))", i, 1, n))[br]Execute(Sequence("SetValue(F"+i+", RandomUniform(-0.3, 0.3))", i, 1, n))[br][br]#---------------------------------------[br]#Attractor[br]#---------------------------------------[br]Otx=Slider(-15,15, 0.001, 1, 140, false, true, false, false)[br]Oty=Slider(-10,10, 0.001, 1, 140, false, true, false, false)[br]SetVisibleInView(Otx, 1, false)[br]SetVisibleInView(Oty, 1, false)[br][br]A=(Otx, Oty)[br][br]#---------------------------------------[br]# Direction[br]#---------------------------------------[br]Execute(Sequence("G"+i+"=Otx-A"+i+"", i, 1, n))[br]Execute(Sequence("H"+i+"=Oty-B"+i+"", i, 1, n))[br]Execute(Sequence("I"+i+"=sqrt( (G"+i+")^2+(H"+i+")^2 )", i, 1, n))[br]Execute(Sequence("S"+i+"=RandomUniform(0.0005, 0.009)"+i+"", i, 1, n))[br]Execute(Sequence("T"+i+"=RandomUniform(0.0005, 0.009)"+i+"", i, 1, n))[br]#scale=0.06[br][br]#---------------------------------------[br]# Acceleration[br]#---------------------------------------[br]##normalize and scale##[br]Execute(Sequence("J"+i+"=(Otx-A"+i+")/I"+i+"*S"+i+"", i, 1, n))[br]Execute(Sequence("K"+i+"=(Oty-B"+i+")/I"+i+"*T"+i+"", i, 1, n))[br][br]#---------------------------------------[br]# Stars[br]#---------------------------------------[br]r(α) = 1.5(0.4 + 0.1*sin(5α))[br]SetVisibleInView(r, 1, false)[br]#star = Curve((r(α);α)+(x, y), α, 0, 2pi)[br]Execute(Sequence("C"+i+"=atan2(B"+i+", A"+i+")", i, 1, n))[br]Execute(Sequence("SetVisibleInView(C"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("D"+i+"= Rotate( Curve((r(α);α)+(A"+i+", B"+i+"), α, 0, 2pi), C"+i+", (A"+i+", B"+i+") )", i, 1, n))[br]Execute(Sequence("SetDynamicColor(D"+i+", 255/255, 215/255, 0/255, 1)", i, 1, n))[br][br]#---------------------------------------[br]# For animation[br]#---------------------------------------[br]Run=Slider(-5, 5, 0.01, 1, 140, false, true, false, false)[br]ShowLabel(Run, false)[br]SetVisibleInView(Run, 1, false)[br][br]#------------------------------------------------------[br]#After Run is defined add this script in Update[br]#------------------------------------------------------[br]#Execute(Sequence("SetValue(E"+i+", E"+i+" + J"+i+" )", i, 1, n))[br]#Execute(Sequence("SetValue(F"+i+", F"+i+" + K"+i+" )", i, 1, n))[br][br]#Execute(Sequence("SetValue(A"+i+", A"+i+" + E"+i+" )", i, 1, n))[br]#Execute(Sequence("SetValue(B"+i+", B"+i+" + F"+i+" )", i, 1, n))[br][br]#---------------------------------------[br]#Extra settings[br]#---------------------------------------[br][br]SetBackgroundColor("Black")[br]ShowAxes(false)[br]ShowGrid(false)[br][br]a=false[br]SetValue(a, false)[br]SetColor(a, "White")