How to plot the volume shared by two 3D shapes
1 回表示 (過去 30 日間)
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 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().