How to plot the volume shared by two 3D shapes

6 visualizaciones (últimos 30 días)
Michael Boyte
Michael Boyte el 1 de Feb. de 2023
Comentada: William Rose el 1 de Feb. de 2023
I have two identical spheres offset from each other by a distance less than their radiuses. I would like to plot just the volume that is shared by these two spheres. How can I do this? Also, I need to be able to scale the solution to include more spheres.

Respuesta aceptada

William Rose
William Rose el 1 de Feb. de 2023
patch() and fill3() are options worth considering.
With either approach, you will have define the lens-shaped intersection of 2 spheres as a polygon. When there are just 2 spheres, there are formulas for the radius of the circular edge of the lens, the height of each "half" of the lens, and the location of the center of the lens. See here for those formulas. The formulas above assume one sphere is at the orign and the other is centered on the x-axis. If your spheres do not meet this assumption, you would do a translation and rotation first, so that the shere centers are at the origin and on the x-axis, then apply the formulas from Wolfram, then compute the polygons, the translate and rotate back, then plot with patch() or fill3().
If you add additional spheres, the intersection will no longer be a lens shape with well-defined formulas. In this case, I would use numerical methods to find a set of points that are inside all three spheres, then I would wrap a convex hull around it with convhull().
  1 comentario
William Rose
William Rose el 1 de Feb. de 2023
The attached script plots the intersection of two spheres. Specify R1, R2, and d, in the code, then run the code. R1 and R2 are sphere radii. Sphere 1 is centered at the origin. Sphere 2 is centered at (d,0,0).
Screenshot 1 shows the result when R1=R2=1, and d=1.5. In this case the intersection is a symmetric lens of total thickness 0.5, with center at x=0.75. I used the rotate tool in the figure window to drag the object to the orientation shown here.
Screenshot 2 shows the result when R1=1, R2=10, and d=10. In this case, the interesection is roughly the +x hemisphere of sphere 1.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by