How to find the equation of the curve that intersects a 3D surface and a plane
9 次查看(过去 30 天)
显示 更早的评论
Hello, everyone:
I want to calculate the volume of the solid boundary between the surface and two cubes using integral.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149336/image.png)
I have read this topic 'How do I find the equation of the line that intersects a 3D surface and a plane passing through 3 points of interest on the surface?' and my idea is therefore to fit a polynomial function of the surface (f(x,y)= z = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2)and the intersection between the top plane of the cube and the surface is curveFun: C = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 and C is the height of the top plane, which is a constant.
This is part of my code:
% to generate the surF, suppose coef are known
zFun = '';
for i=1:np
for j=1:np
P = char(vpa(coef(i,j),40));
if coef(i,j) < 0
Sign = ' ';
else
Sign = ' +';
end
I = num2str(i-1);
J = num2str(j-1);
zFun = [zFun Sign P '*x^' I '*y^' J];
% q = q + 1;
end
end
sym x,y
surF = matlabFunction(sym(zFun));
% to calculate the volume under the surface
vol = quad2d(surF,xleft,xright,downY,upY);
% to calculate the volume between the surface and top plane
fun=@(x,y,z)x.^0+y.^0+z.^0;
q = integral3(fun,xleft,xright,Ydown,CurveFun,C,surF);
To calculate the volume under the surface, I can use double integral, which only need the xmin, xmax, ymin, ymax and surfF.
Now for the volume between the surface and the upper cube, I can use the triple integral or I double integral if I know the curve function. Now, how can I construct the curveFun for this triple integral ? The topic mention I can use the Symbolic Math Toolbox to simplify the curve function but I don't know how.
Also, I 'd like to know if there is a better solution to calculate the volume.
I have tried triangulation and the volume under the surface is the sum of these prisms, but the calculation accuracy is largely depended on the number of points I can have.
Many thanks.
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!