<jupyter_start><jupyter_text>The three lines of code perform the adaptive sampling.<jupyter_code># The radius function determines the radius of a dart hitting the point (x, y)
radius_function = (lambda x, y: (1.0 - math.sqrt(y)) * 0.1 + 0.01)

# The adaptive sampling method takes the radius function as input to determine sample radii
samples = slowAdaptiveDartThrowingWithBoundary(radius_function, stop_count = 1000)

# Convert the samples, which are tuples of floats (x, y) to PointE2 objects
samplePoints = [PointE2(2*sample[0] - 1, 2*sample[1] - 1) for sample in samples]<jupyter_output><empty_output><jupyter_text>The three lines below will allow you to visualize the point set.<jupyter_code>viewer = UnitScaleE2Sketch()
viewer.addAll(samplePoints)
viewer.show()<jupyter_output><empty_output><jupyter_text>Now we want to triangulate, so we are going to project everything onto the sphere.<jupyter_code>s2points = [PointS2.sgProjectFromPointE2(p) for p in samplePoints]

pts = [(sp.directionE3.vec * (1 + random() / 10000)).toPointE3() for sp in s2points]
mesh = incrConvexHull(pts + [PointE3(0,0,-1)], orientationPointE3)
mesh.outerFace = mesh.verts[-1].remove()

viewer = S2Viewer()
viewer.toggleSphere()
viewer.addAll(pts)
viewer.addAll(mesh.edges)
viewer.addAll(mesh.faces)
viewer.show()
mesh2 = mesh.duplicate(
    vdata_transform = (lambda v : PointS2(v.x, v.y, v.z).sgProjectToPointE2())
)
viewer = UnitScaleE2Sketch()
viewer.addAll(mesh2.verts)
viewer.addAll(mesh2.edges)
viewer.show()
vtoi = dict([(v, k) for k, v in enumerate(mesh2.verts)])

# convert a face to a string:
f_to_s = (lambda f : [vtoi[v] for v in f.vertices()])

# Because of the random perturbation we are using, we get some degenerate triangles 
# along the boundary and have to filter them out. 
def valid_face(f):
    vcoords = [tuple(v.data) for v in f.vertices()]
    return ((vcoords[0][0] != vcoords[1][0] or vcoords[1][0] != vcoords[2][0] or vcoords[0][0] != vcoords[2][0]) 
            and (vcoords[0][1] != vcoords[1][1] or vcoords[1][1] != vcoords[2][1] or vcoords[0][1] != vcoords[2][1]))

faces = [f for f in mesh2.faces if valid_face(f)]
vert_string = "".join([f"{x} {y}\n" for x, y in [tuple(v.data) for v in mesh2.verts]])
triangle_string = "".join([f"{i} {j} {k}\n" for i, j, k in [f_to_s(f) for f in faces if f != mesh2.outerFace]])

out_string = f"vertex-count triangle-count\n{len(mesh2.verts)} {len(faces)}\n" + vert_string + triangle_string
import itertools<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14423463238248294, 'fraction_numerical': 0.029730815588589796, 'mean_word_length': 5.3520408163265305, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '92659', 'license': 'MIT', 'n_tokens_mistral': 959, 'n_tokens_neox': 930, 'n_words': 254, 'path': 'Example Notebooks/Poisson Disk Sampling Examples.ipynb', 'repo_name': 'johncbowers/koebepy', 'size': '2489'}