Voronoi diagram on sphere

[size=150]Drag Points on sphere. Press buttons to see different distributions of points on the sphere.[br][br][/size]Have fun! :-)
[size=150]#=======================[br]# Inspired by Daniel Mentrard[br]#=======================[br][br]#=======================[br]# Initial values[br]#=======================[br][br]N = 100[br]M = Slider(10, N, 1, 1, 160, false, true, false, false)[br]SetValue(M, N)[br]Lm = Sequence(1, M)[br][br]speed = 0.001[br]a = Slider(0, 6.2812, 0.001, speed, 140, false, true, false, false)[br]SetValue(a, 1 / 2 + sqrt(5) / 2)[br][br]#=======================[br]# Functions[br]#=======================[br][br]Px(x) = cos(pi * 2 * a * x) * sin(acos(1 - 2 * x / M))[br]Py(x) = sin(pi * 2 * a * x ) * sin(acos(1 - 2 * x / M))[br]Pz(x) = cos(acos(1 - 2 * x / M))[br][br]#=======================[br]# Main sphere[br]#=======================[br][br]O = (0,0,0)[br]s = Sphere(O, 1)[br][br]#=======================[br]# List of names for centers and spheres[br]#=======================[br][br]Sname = Zip("sphere"+Text(m), m, Lm)[br]Pname = Zip("C"+Text(m), m, Lm)[br]PMname = Zip("M"+Text(m), m, Lm)[br][br]#=======================[br]# Points and spheres[br]#=======================[br][br]Execute(Zip(name" = PointIn(s)", name, Pname))[br]Execute(Zip(name" = Midpoint("+P+", O)", name, PMname, P, Pname))[br]Execute(Zip(name" = Sphere( "+Mname+", 1 / 2 )", name, Sname, Mname, PMname))[br][br]Execute(Zip("ShowLabel("+name+", false)", name, Sname))[br]Execute(Zip("ShowLabel("+name+", false)", name, Pname))[br]Execute(Zip("SetVisibleInView("+name+", -1, false)", name, PMname))[br][br]Cols = Zip(random(), k, Lm)[br]Execute(Zip("SetDynamicColor("+name+", "+hue+", 0.85, 1, 1)", name, Sname, hue, Cols))[br]Execute(Zip("SetConditionToShowObject("+name+", "+k+"<=M)", name, Sname, k, Lm))[br][br]colP = "Black"[br]Execute(Zip("SetPointSize("+name+", 4)", name, Pname))[br]Execute(Zip("SetVisibleInView("+name+", 1, false)", name, Pname))[br]Execute(Zip("SetColor("+name+", colP)", name, Pname))[br][br]Lx = Zip( sin(pi * random()) * cos(2 * pi * random()), k, Lm)[br]Ly = Zip( sin(pi * random()) * sin(2 * pi * random()), k, Lm)[br]Lz = Zip( cos(pi * random()), k, Lm)[br][br]#Random distribution[br]#Execute(Zip("SetValue("+name+", ("+Px+", "+Py+", "+Pz+"))", name, Pname, Px, Lx, Py, Ly, Pz, Lz))[br]#Nice distribution :-)[br]Execute(Zip("SetValue("+name+", ( Px("+k+"), Py("+k+"), Pz("+k+") ))", name, Pname, k, Lm))[br][br]#=======================[br]# Settings :-)[br]#=======================[br][br]SetVisibleInView(M, 1, false)[br][br]SetVisibleInView(a, 1, false)[br][br]SetVisibleInView(s, -1, false)[br][br]SetVisibleInView(Px, 1, false)[br]SetVisibleInView(Py, 1, false)[br]SetVisibleInView(Pz, 1, false)[br]SetVisibleInView(Px, -1, false)[br]SetVisibleInView(Py, -1, false)[br]SetVisibleInView(Pz, -1, false)[br][br]SetVisibleInView(Pname, 1, false)[br]SetVisibleInView(PMname, 1, false)[br]SetVisibleInView(Sname, 1, false)[br]SetVisibleInView(Pname, -1, false)[br]SetVisibleInView(PMname, -1, false)[br]SetVisibleInView(Sname, -1, false)[br][br]ShowAxes(false)[br]ShowGrid(false)[br]SetBackgroundColor("GAINSBORO")[/size]

Information: Voronoi diagram on sphere