-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Description
Dear developer,
I am trying to convert a point cloud to an SDF object. I have an array of XYZs. I have been trying the following:
from sdf import *
def place_bead(x, y, z, size):
"""
Creates a SDF sphere of given size at the
indicated position.
"""
bead = sphere(size)
bead.translate(X*x)
bead.translate(Y*y)
bead.translate(Z*z)
return bead
# Setting some sphere properties
size = dict()
aa_names_list = ['oxygen', 'hydrogen', 'carbon']
aa_sizes_list = [.152, .120, .170]
size_dict = dict(zip(aa_names_list, aa_sizes_list))
# Generating some data, the goal is a some spheres on a line. However
# this will be practically random XYZs in the real case.
aa_xpositions = np.arange(100)
aa_ypositions = np.zeros(100)
aa_zpositions = np.zeros(100)
aa_types = np.random.choice(aa_names_list[:3], 100)
aa_sizes = np.asarray([size_dict[aa_type] for aa_type in aa_types])
aa_array = np.vstack([aa_xpositions, aa_ypositions, aa_zpositions, aa_sizes]).T
aa_objects = [place_bead(*bead) for bead in aa_array]
# Generating the unified SDF
s = aa_objects[0]
for aa_object in aa_objects[1:]:
s.union(aa_object)
However, I always end up with just a single sphere. Also it feels pretty convoluted, but as I am only aiming at small point clouds for now (for sure less than a 1000) I do do not worry too much about the performance.
It would be great if you could nudge me in the right direction.
Cheers,
Bart
Metadata
Metadata
Assignees
Labels
No labels