フィルターのクリア

How to fill a 3d volume with non-overlapping structures?

3 ビュー (過去 30 日間)
Carson Purnell
Carson Purnell 2022 年 2 月 28 日
編集済み: Carson Purnell 2022 年 3 月 25 日
I have a problem that I haven't seem any general solution for in other answers. I need to randomly place arbitrary, irregular shapes (macromolecules, if it matters) into a 3d array volume without overlapping. I don't need packing, but ideally being ale to hit high density is good.
I have a few hamfisted ideas of how to do this, all of which seem inelegant, slow, and error-prone:
  1. add a uniform high value to all prospective inputs, check for overlap via finding excessively high values after placement and reverting if an overlap value is generated in the array. Seems the most ideal, as it works well with irregular shapes.
  2. randomly choose a centroid, and exhaustively check hundreds-thousands of points within the prospective object's radius to find if anything else is present. place only if nothing is found.
  3. generate centroids as plot points, finding the nearest points and checking that the combined radius doesn't overstep the distance
Is there any more simple and reliable way to do this? A function that could do a basic overlap check? something on the file exchange that already accumulates shapes into a 3d volume without overlap? Or just a better strategy?
  3 件のコメント
Matt J
Matt J 2022 年 3 月 1 日
Are the instances of the shapes all the same size and geometry?
Carson Purnell
Carson Purnell 2022 年 3 月 1 日
The shapes are a mixed collection with high variance.

サインインしてコメントする。

採用された回答

Carson Purnell
Carson Purnell 2022 年 3 月 3 日
編集済み: Carson Purnell 2022 年 3 月 25 日
To answer my own question, I went with #1. it ended up being very efficient, combined with a refactoring of the function I was using to write into the destination array it ended up being a dramatic increase in speed.
Binarize the relevant areas, sum and check for overlap (>1), only write if there is no overlap.
case 'nonoverlap'
dbin = single(imbinarize(dest(dx,dy,dz))); sbin = single(imbinarize(source(sx,sy,sz)));
overlap = dbin + sbin;
if max(max(max(overlap)))>1 %if overlap, record and output original
overlap = 1;
else %if no overlap, add the source to the destination
dest(dx,dy,dz) = source(sx,sy,sz) + dest(dx,dy,dz); overlap = 0;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by