How to plot the volume shared by two 3D shapes

1 ビュー (過去 30 日間)
Michael Boyte
Michael Boyte 2023 年 2 月 1 日
コメント済み: William Rose 2023 年 2 月 1 日
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.


William Rose
William Rose 2023 年 2 月 1 日
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 件のコメント
William Rose
William Rose 2023 年 2 月 1 日
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.


その他の回答 (0 件)


Find more on Lighting, Transparency, and Shading in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by