I have plotted three cones which are intersecting each other at certain height. I need to find out the common volume of the intersection but I can't figure that out! Is there any built-in function in MATLAB, which can calculate the volume of interest? I would also like to highlight that region with stronger color. Any advice?
The plotted picture can be seen below:
Regards, TK
I'll illustrate the principle with a similar triple intersection, replacing two of the cones by cylinders. (Also, I'm not answering about coloring. One question per question, please.)
Suppose I want the volume within the cone z=x^2+y^2, cylinder x^2+(z-2)^2=1, and cylinder y^2+(z-2)^2 = 1. The cone bounds the solid from below only. The cylinders can do it from the top and from the bottom: solving their equations for z gives two values, top and bottom.
The vertical size of the solid over a point (x,y) can be found as
Specifically:
Which outputs 5.3333.
Note that
sqrt(max(0,...))
is used to prevent Matlab from getting complex numbers, should the content of square root be negative. This is useful because the limits of integration (-1,1,-1,1 above) generally correspond to some bounding rectangle for the projection onto xy-plane, so within this rectangle some of the formulas might not be really defined. For example, you could useto get the same result, although the equations of cylinders break down when |x| or |y| exceed 1.