I am trying to to construct a certain number of ellipsoids distributed randomly in a certain circle radius. I want to avoid overlaps between the ellipsoids i a certain way. I have asked a similar question but with spheres instead of ellipsoids, and i have got a good answer about that topic, however with ellipsoids, it is relatively more complicated as the minimum distance between two sister volumes can not be just the radius, because of the three different semi axes.
So i want to ask please, if there is any way to check the overlaps and reject the generated volume if overlaps is encoutered ? Or even a mathematical method to ensure that no overalps will be obtained ?
Thanks in advance,
An ellipsoid can be encapsulated by a sphere, so, there is no big difference between the algorithms for sphere and ellipsoid.
Thank you for your response,
But there still a problem, because when encaspulating the ellipsoids by spheres an overlap between the spheres is encountered but not with the contained ellipsoids as it can be seen in the attached image, so in this case the ellipsoids will be rejected while they are not overlapped.
So i want to ask please, is there any function in Geant4 that can be used to check if there overlaps between two sister volumes, so we can reject the newely contructed volume in case there is overlap and propose a new position ?
- In principle
G4PVPlacement has a method
G4PVPlacement.hh), that can be used to detect overlaps with already existing sister volumes. If an overlap exits then the volume can be deleted from the physical volume store (see
But myself I never tried this. Also take into account that the overlap check in Geant4 is based on the MC method and for large number of ellipsoids it may take time. For 1000 ellipsoids, it’s Okay.
- In case if the ellipsoids have same shape and same orientation, then you can try to generate positions in the scaled space, where all ellipsoids are transformed to sphere, and then re-scale the space to the original one.