本文介绍了可视化在Matlab的环形表面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,这是双重的:

I have a problem which is twofold:

  1. 如何绘制在MATLAB环形表面,赋予了大半径的研究的和一个小半径的的?为了避免混淆,它是环形/极向坐标系,在下面的图片说明,我敢谈论。

  1. How do I plot a toroidal surface in MATLAB, given a major radius R and a minor radius a? To avoid confusion, it is the toroidal/poloidal coordinate system, illustrated in the picture below, that I'm talking about.

现在,在这个表面任何一点的(PHI,THETA)的,小半径将由我已经存储在一个矩阵一定的价值扭曲。如何绘制这个扭曲的面?这可能是很容易,一旦我找到了答案,以第1部分,但是这是我的实际目标,因此任何解决方案,第1部分不能处理,这是pretty的对我没用。

Now, in any point (p theta) on this surface, the minor radius will be distorted by some value that I have stored in a matrix. How do I plot this distorted surface? This might be easy once I have the answer to part 1, but this is my actual goal, so any solution to part 1 that cannot handle this is pretty useless to me.

如果有人能告诉我如何使图像显得更小在这里,请不要=)

推荐答案

解决您的第一个问题:首先你需要定义在环形坐标的圆环的坐标(似乎很自然!),然后转换成直角坐标系,这是MATLAB如何期望所有地块待建(除非你是制作过程的极坐标图,)。因此,我们定义我们的环形开始的坐标:

Addressing your first question: first you will need to define the coordinates of your torus in toroidal coordinates (seems natural!) and then convert to Cartesian coordinates, which is how MATLAB expects all plots to be constructed (unless you are making a polar plot, of course). So we start of by defining our toroidal coordinates:

aminor = 1.; % Torus minor radius
Rmajor = 3.; % Torus major radius

theta  = linspace(-pi, pi, 64)   ; % Poloidal angle
phi    = linspace(0., 2.*pi, 64) ; % Toroidal angle

我们只想环面的一个表面,所以小半径是标量。我们现在做这些坐标的二维网:

We just want a single surface of the torus, so the minor radius is a scalar. We now make a 2D mesh of these coordinates:

[t, p] = meshgrid(phi, theta);

和使用维基百科页面中的问题,联系到上给出的公式坐标转换为三维直角坐标:

and convert to 3D Cartesian coordinates using the formulas given on the Wikipedia page linked to in the question:

x = (Rmajor + aminor.*cos(p)) .* cos(t);
y = (Rmajor + aminor.*cos(p)) .* sin(t);
z = aminor.*sin(p);

现在我们已经在我们的三维环面的定义,我们可以使用 冲浪

Now we have our torus defined in 3D, we can plot it using surf:

surf(x, y, z)
axis equal

修改:为了解决第二个问题,这取决于你如何有你的扭曲存储,但说你有在每一个环形和极向点定义了一个矩阵,你就只能乘常数是由失真小半径。在下面我创建失真矩阵是相同的尺寸我的环形和极向角坐标矩阵和一个正态分布大约平均1以0.1的FWHM:

Edit: To address your second question, it depends how you have your distortions stored, but say you have a matrix defined at each toroidal and poloidal point, you will just have to multiply the constant that is the minor radius by the distortion. In the following I create a distortion matrix that is the same dimensions as my toroidal and poloidal angle coordinate matrices and that is normally distributed about a mean of 1 with a FWHM of 0.1:

distortion = 1. + 0.1 * randn(64, 64);

x = (Rmajor + aminor .* distortion .*cos(p)) .* cos(t);
y = (Rmajor + aminor .* distortion .* cos(p)) .* sin(t);
z = aminor.* distortion .* sin(p);

surf(x, y, z)

其中的结果是:

The result of which is:

这篇关于可视化在Matlab的环形表面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:22
查看更多