How to plot only selected spheres?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have plotted spheres in space from known coordinates and radius. All the spheres are randomly distributed in space. I want to plot only those spheres which are intersecting with each other from top to bottom along the z-axis. I dont want to plot the rest of spheres. Is there any way to do it? I am doing it manually which is wasting a lot of my time. I see only for those spheres which are in continuity and deleting the rest spheres manually which is quite frustrating. Your help and suggestions would be highly appreciated.
0 comentarios
Respuestas (1)
Image Analyst
el 4 de Feb. de 2016
For each sphere, compute the distance of it's center to the centers of all the other spheres. If the distance is less than the sum or their two radii, then those two spheres overlap, and record/log that pair of spheres. Then, once all overlapping pairs have been identified, clear the axes or use a new one and plot only those spheres that had overlap. Code should be straightfoward. Let me know if you can't figure it out. Here's a start, assuming you have an array xyzr with one row for every sphere
numSpheres = size(xyzr, 1);
for k = 1 : numSpheres
distances = sqrt((xyzr(:, 1) - xyzr(k, 1))^2 + (xyzr(:, 2) - xyzr(k, 2))^2 + (xyzr(:, 3) - xyzr(k, 3))^2)
sumOfRadii = xyzr(k, 4) + xyzr(:, 4);
overlaps = distances < sumOfRadii;
indexes = find(................
end
% etc.
That should be a good start. See if you can finish it.
2 comentarios
Image Analyst
el 4 de Feb. de 2016
Each sphere has an index - some kind of ID number to identify it. Why didn't you just keep track of those that had the distance less than the sum of the radii?
overlaps = distances < sumOfRadii;
indexes = find(overlaps); % Keep track of indexes that overlap the k'th sphere.
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!