繁体   English   中英

如何在MatLab中两个曲面的交点处获取切片数据

[英]How to get slice data at the intersection of two surfaces in MatLab

我在NxMxP数组中有流数据,我想在两个曲面的交点处找到数据的值。 目前,我正在使用平面和圆柱体,但是将来,如果可能的话,我想使用其他形状并在相交圆弧上查找数据。

下面是飞机和圆柱体的图片,以及我制作它们的代码。 红线是我要获取数据的交点。

AR = 5;    R = 2.5;
Ny = 200;
% generate plane
[x, y] = meshgrid(-(AR+1):(AR+1)/Ny:0, ...
        -0.7344:(0.7031- -0.7344)/Ny:0.7031); % Generate x and y data
z = zeros(size(x, 1)); % Generate z data
% I needed to rotate the plane by an angle about y-axis for my purposes
V1 = [reshape(x,1,(Ny+1)^2);
    reshape(y,1,(Ny+1)^2);
    reshape(z,1,(Ny+1)^2)];
dphi = 7.5;    % angle to rotate in degrees
MR = [cosd(dphi) 0 -sind(dphi);...
    0 1 0;...
    sind(dphi) 0 cosd(dphi)];
% slice going through the center of the wing
VR1 = MR*V1;
xP = reshape(VR1(1,:),Ny+1,Ny+1);
yP = reshape(VR1(2,:),Ny+1,Ny+1);
zP = reshape(VR1(3,:),Ny+1,Ny+1);

% generate cylinder
Nt = floor(2.1*Ny*R);   % specify the number of nodes along the tangential axis
[Xc,Zc,Yc] = cylinder(R*ones(1,Ny),Nt);
% matrix for correcting the height of cylindrical slice
ty = -0.7344;
sy = 0.7031 - -0.7344;
Mt = [1 0 0 0;
    0 1 0 ty;   % vertical translation
    0 0 1 0;
    0 0 0 1];
Ms = [1 0 0 0;
    0 sy 0 0;   % vertical stretching
    0 0 1 0;
    0 0 0 1];
H = Mt*Ms*[ones(1,Ny);Yc(:,1)';ones(1,Ny);ones(1,Ny)];
Yc = repmat(H(2,1:Ny)',1,Nt+1);

% draw figure
figure
hold on
h1 = slice(Xw,Yw,Zw,ur,xP,yP,zP,'linear');
plane_sli = h1.CData;
set(plane_sli,'edgecolor','none')
h2 = slice(Xw,Yw,Zw,ur,Xc,Yc,Zc,'linear');
cyl_sli = h2.CData;
set(cyl_sli,'edgecolor','none')
axis equal

附加工作:尝试inShape按照MathWorks网站上有关inShape的说明进行操作,如下所示。

shp = alphaShape(xP(:),yP(:),zP(:));
tf = inShape(shp,xC(:),yC(:),zC(:));

tf变量只是一个空( Nt * Ny )x 1数组。 也许我做错了,但似乎没有用。

两个表面

这是一个开始:您可以在平面(Xa,Ya,Za)上进行迭代,并使用inShape查看与圆柱体(Xb,Yb,Zb)相交的位置; 参见https://www.mathworks.com/matlabcentral/answers/392798-finding-intersecting-points-of-two-3d-bodies

将来,您可以将其概括化以遍历平面的横截面(例如长方体),然后尝试使用二进制搜索,这样就不必遍历所有横截面。 有趣的问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM