使用Matlab进行3D绘图

用户名

我想使用MATLAB制作3D画家。

首先我想显示3个面板- XYXZYZ意见。

用户将在每个面板中绘制他想要的内容。

之后,他将单击按钮来组合这3个视图,并从这些面板中获得3d模型。他还可以自由渲染此模型。

我怎样才能做到这一点?

这些图片说明了我想要的:

2D视图:
2D视图

合并3个视图后的3D对象
3D物件

哈巴德兹

I am assuming that you only want to specify 3D lines and no solid blocks (as in the linked example). There I see a small problem: after specifying the XY and XZ projections, you have a x, y and z value for each point on the curve, so the YZ projection is already defined. It is therefore enough to specify only the XY and XZ dimension. Here's how to do that:

To get a graphical input from the user, you can use the ginput function, which creates a figure and allows the user to select points:

[x,y,btn] = ginput(k);

where x and y are the coordinates of the selected points, btn the ASCII code of any clicked button, and k is the number of points to get. You can let the user draw something and let the drawing end by pressing the space bar by:

figure; axis([0 1 0 1]);              % create empty figure
button=0; k=1;                        % set start values
while button~=' '                     % repeat until space is pressed
    [x(k) y(k), button] = ginput(1);  % get one point
    k=k+1;                            % set k for next iteration
    plot(x,y);axis([0 1 0 1]);        % plot the curve
end

您可以重复两次以获取XY和XZ视图。假设您将坐标保存到变量中

(x1, y1)    % the XY view
(x2, z2)    % the XZ view

现在,您可以通过创建x矢量并对所有yz值进行插值来创建最终的3D曲线为了获得良好的平滑曲线,我建议使用样条插值法:

x = 0:0.01:1;
y = interp1(x1,y1,x,'spline','extrap');    % Spline interpolation + extrapolation
z = interp1(x2,z2,x,'spline','extrap');    % Spline interpolation + extrapolation

现在,只需使用plot3函数将其绘制在3D中即可

plot3(x,y,z);

您可以轻松地扩展此最小示例以执行所需的任何操作,这只是为了展示MATLAB中的基本步骤和可能性。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用Matlab进行3D绘图

来自分类Dev

使用matplotlib进行连续3d绘图

来自分类Dev

使用matplotlib从导入的数据进行3D绘图

来自分类Dev

在Matlab中从3D矩阵绘图

来自分类Dev

如何进行3D绘图?

来自分类Dev

在3D中插值,使用matplotlib进行绘图-出了点问题

来自分类Dev

替代Mayavi进行科学3D绘图

来自分类Dev

使用MATLAB进行高尔顿偏度和摩尔峰度的3-D绘图

来自分类Dev

使用Matlab中的内置功能进行3D重建(radon和iradon)

来自分类Dev

MATLAB,将 4049 行 x 50 列的光谱数据转换为 3D 绘图

来自分类Dev

在MATLAB中对3D数组进行排序和索引

来自分类Dev

MATLAB:对3D数组进行矢量化填充

来自分类Dev

如何在ILArray中加载大型CSV文件以进行3D绘图?

来自分类Dev

Python:根据点值进行一致的3D绘图

来自分类Dev

怪异的逐像素3d绘图程序[通过拖动窗口进行快速绘制]

来自分类Dev

矩阵到数据框,以便更轻松地进行3D绘图

来自分类Dev

Python:根据点值进行一致的3D绘图

来自分类Dev

在Matlab中使用For循环进行绘图

来自分类Dev

使用滑块在Matlab中进行实时绘图

来自分类Dev

使用滑块在Matlab中进行实时绘图

来自分类Dev

3D绘图长宽比[matplotlib]

来自分类Dev

SceneKit –在3D对象上绘图

来自分类Dev

3D绘图中的尺寸问题

来自分类Dev

SceneKit –在3D对象上绘图

来自分类Dev

Dirichlet 3D绘图遇到麻烦

来自分类Dev

错误的 GNU Octave 3D 绘图

来自分类Dev

R 错误中的 3D 绘图

来自分类Dev

HelixToolkit 和 3d 绘图

来自分类Dev

使用plot3d在单个绘图窗口中绘制多个3D图像