使用 matlab 拉伸二维轮廓
Extruding a 2D profile using matlab
我在 Matlab 上有一个用两个坐标向量 x 和 y 定义的二维轮廓。我想为轮廓指定厚度,以便 'extrude it' 并将其转换为 3D 表面。就像 CAD 程序如何将 2D 轮廓挤压成 3D 形状一样。
这张图完美诠释了它:
谁能指导我正确的方向?
谢谢!
@Dev-iL 是对的。你可以像这样轻松地做到这一点:
x = randi(100,1,5);
y = randi(100,1,5);
x = x([1:end 1]);
y = y([1:end 1]);
bw = poly2mask(x,y,100,100);
figure;
subplot(121);
plot(x,y)
[xg,yg] = meshgrid(1:100);
zg = bw * 2;
subplot(122);
surf(xg,yg,zg,'EdgeColor','none','FaceColor','interp','FaceLighting','gouraud')
material shiny
你会得到:
我在 Matlab 上有一个用两个坐标向量 x 和 y 定义的二维轮廓。我想为轮廓指定厚度,以便 'extrude it' 并将其转换为 3D 表面。就像 CAD 程序如何将 2D 轮廓挤压成 3D 形状一样。
这张图完美诠释了它:
谁能指导我正确的方向?
谢谢!
@Dev-iL 是对的。你可以像这样轻松地做到这一点:
x = randi(100,1,5);
y = randi(100,1,5);
x = x([1:end 1]);
y = y([1:end 1]);
bw = poly2mask(x,y,100,100);
figure;
subplot(121);
plot(x,y)
[xg,yg] = meshgrid(1:100);
zg = bw * 2;
subplot(122);
surf(xg,yg,zg,'EdgeColor','none','FaceColor','interp','FaceLighting','gouraud')
material shiny
你会得到: