```__author__ = 'thoth' # # This is just a hack to visualize point density distribution of two # different methods of picking random points on a sphere. # # random_sphere_1 is evenly distributed, while random_sphere_2 has # higher point density at the poles. # import bpy from math import * from random import * def random_sphere_1(r, n): mesh = bpy.data.meshes.new("uniform") verts = [] for i in range(n): theta = asin(random()*2-1) phi = random()*2*pi z = sin(theta)*r q = cos(theta)*r x = q*cos(phi) y = q*sin(phi) verts.append( [x,y,z] ) mesh.from_pydata(verts, [], []) return mesh def random_sphere_2(r, n): mesh = bpy.data.meshes.new("polar") verts = [] for i in range(n): theta = random()*2*pi phi = random()*2*pi z = sin(theta)*r q = cos(theta)*r x = q*cos(phi) y = q*sin(phi) verts.append( [x,y,z] ) mesh.from_pydata(verts, [], []) return mesh # scn = bpy.context.scene r = 2 n=5000 s1 = bpy.data.objects.new("uniform", random_sphere_1(r, n)) s1.location = [-4,0,0] scn.objects.link(s1) s2 = bpy.data.objects.new("polar", random_sphere_2(r, n)) s2.location = [4,0,0] scn.objects.link(s2) ```

Syntax highlighting by Pygments.