procedurally generate a sphere mesh

后端 未结 5 1006
既然无缘
既然无缘 2020-12-13 02:38

i am looking for an algorithm ( in pseudo code) that generates the 3d coordinates of a sphere mesh like this:

\"

5条回答
  •  一生所求
    2020-12-13 03:11

    FWIW, you can use meshzoo (a project of mine) to generate meshes on spheres very easily.

    You can optionally use optimesh (another one out of my stash) to optimize even further.

    import meshzoo
    import optimesh
    
    points, cells = meshzoo.icosa_sphere(10)
    
    
    class Sphere:
        def f(self, x):
            return (x[0] ** 2 + x[1] ** 2 + x[2] ** 2) - 1.0
    
        def grad(self, x):
            return 2 * x
    
    points, cells = optimesh.cvt.quasi_newton_uniform_full(
        points, cells, 1.0e-2, 100, verbose=False,
        implicit_surface=Sphere(),
        # step_filename_format="out{:03d}.vtk"
    )
    

提交回复
热议问题