sdf
sdf copied to clipboard
Point cloud to SDF?
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
At a glance, you may need s = s.union(aa_object)
instead of s.union(aa_object)
. Or just s = union(*aa_objects)
I will try this fix, for now the second option I suggested is working so I think I am happy.
Hoi Fogleman,
I have a small working example for the SDF volume using the meshing approach. In it I generate some random coordinates to use for creating the SDF molecules. In the real cases we would get those coordinates from similar arrays, as many file parsers exist using the python framework. For example we use PDF or GRO which are easily parsed by MDAnalysis. Anyway I hope the notebook shows what we are intending to achieve. It uses open3d for rending the results which can be quite nice when working with these fields. I tried to compile yours, but for some reason GO really didn't want to do it. Probably something with the glfw but I am not sure.
For now I am not sure about the confidentiality of the project, so I would like to ask to not openly show this code (for now, if it works it will be shared and 100% free imo, like your SDF stuff). If you have a different opinion on this or anything else in the future please feel free to express it, and we'll work it out.
Cheers,
Bart
Op di 15 nov. 2022 om 14:34 schreef VladS-PCH @.***>:
Hi,
Could you please provide a minimal example how to load a point cloud (either from a text file or just an array), and to generate a merged SDF blobs from it? Would much appreciated!
— Reply to this email directly, view it on GitHub https://github.com/fogleman/sdf/issues/35#issuecomment-1315318496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLQB7XF2BSMU5SEODFL4TWIOGNVANCNFSM6AAAAAAR5VASRI . You are receiving this because you authored the thread.Message ID: @.***>
Hoi,
I made a small test example using real molecules and their coarse grained representation. You can find the files here https://transfer.sh/Uu1fA0/volume_matching.tar.gz. The link will stay active for a few days. In the notebook you see how I do it.
Cheers,
Bart
PS As small teaser
[image: vol_diff_transparent.png] [image: vol_diff_chalky.png] [image: vol_diff_chalky_side.png]
Op di 15 nov. 2022 om 16:08 schreef Bart Bruininks @.***
:
Hoi Fogleman,
I have a small working example for the SDF volume using the meshing approach. In it I generate some random coordinates to use for creating the SDF molecules. In the real cases we would get those coordinates from similar arrays, as many file parsers exist using the python framework. For example we use PDF or GRO which are easily parsed by MDAnalysis. Anyway I hope the notebook shows what we are intending to achieve. It uses open3d for rending the results which can be quite nice when working with these fields. I tried to compile yours, but for some reason GO really didn't want to do it. Probably something with the glfw but I am not sure.
For now I am not sure about the confidentiality of the project, so I would like to ask to not openly show this code (for now, if it works it will be shared and 100% free imo, like your SDF stuff). If you have a different opinion on this or anything else in the future please feel free to express it, and we'll work it out.
Cheers,
Bart
Op di 15 nov. 2022 om 14:34 schreef VladS-PCH @.***>:
Hi,
Could you please provide a minimal example how to load a point cloud (either from a text file or just an array), and to generate a merged SDF blobs from it? Would much appreciated!
— Reply to this email directly, view it on GitHub https://github.com/fogleman/sdf/issues/35#issuecomment-1315318496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLQB7XF2BSMU5SEODFL4TWIOGNVANCNFSM6AAAAAAR5VASRI . You are receiving this because you authored the thread.Message ID: @.***>
Sorry for spamming you, but could you let me know if these return emails are actually received?
Cheers,
Bart
Op do 17 nov. 2022 om 13:09 schreef Bart Bruininks @.***
:
Hoi,
I made a small test example using real molecules and their coarse grained representation. You can find the files here https://transfer.sh/Uu1fA0/volume_matching.tar.gz. The link will stay active for a few days. In the notebook you see how I do it.
Cheers,
Bart
PS As small teaser
[image: vol_diff_transparent.png] [image: vol_diff_chalky.png] [image: vol_diff_chalky_side.png]
Op di 15 nov. 2022 om 16:08 schreef Bart Bruininks < @.***>:
Hoi Fogleman,
I have a small working example for the SDF volume using the meshing approach. In it I generate some random coordinates to use for creating the SDF molecules. In the real cases we would get those coordinates from similar arrays, as many file parsers exist using the python framework. For example we use PDF or GRO which are easily parsed by MDAnalysis. Anyway I hope the notebook shows what we are intending to achieve. It uses open3d for rending the results which can be quite nice when working with these fields. I tried to compile yours, but for some reason GO really didn't want to do it. Probably something with the glfw but I am not sure.
For now I am not sure about the confidentiality of the project, so I would like to ask to not openly show this code (for now, if it works it will be shared and 100% free imo, like your SDF stuff). If you have a different opinion on this or anything else in the future please feel free to express it, and we'll work it out.
Cheers,
Bart
Op di 15 nov. 2022 om 14:34 schreef VladS-PCH @.***>:
Hi,
Could you please provide a minimal example how to load a point cloud (either from a text file or just an array), and to generate a merged SDF blobs from it? Would much appreciated!
— Reply to this email directly, view it on GitHub https://github.com/fogleman/sdf/issues/35#issuecomment-1315318496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALLQB7XF2BSMU5SEODFL4TWIOGNVANCNFSM6AAAAAAR5VASRI . You are receiving this because you authored the thread.Message ID: @.***>