How to plot the volume shared by two 3D shapes
9 次查看(过去 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.
0 个评论
采纳的回答
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
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1280946/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1280951/image.png)
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!