使用具有三角测量的Matlab可视化3d红细胞几何

时间:2014-09-30 17:59:42

标签: matlab plot 3d triangulation

我试图通过以下功能可视化3d红细胞几何结构。

z = (+-)7.82*sqrt(1-4*(x^2+y^2)/(7.82*7.82))*(0.0518 + 2.0026*(x^2+y^2)/(7.82*7.82)-4.491*((x^2+y^2)/(7.82*7.82))^2)

我想在几何上随机分布点,然后使用三角测量功能将其可视化。下面是我写的matlab代码。我的观点有问题'设置。我无法得到想法结果,我认为问题是我不知道如何选择x,y参数范围。

% coefficent defination
D_0 = 7.82;
a_0 = 0.0518;
a_1 = 2.0026;
a_2 = -4.491;
D_0_sq = D_0*D_0;

% number of points to be added
numpts = 100;

% coordination compuation
%thetha = rand(numpts,1)*2*pi;
%phi = rand(numpts,1)*pi;

x = rand(numpts,1);
y = rand(numpts,1);
z = D_0*sqrt(1-4*(x.^2 + y.^2)/D_0_sq).*(a_0 + a_1*(x.^2 + y.^2)/D_0_sq + ...
    (a_2*(x.^2 + y.^2).*(x.^2 + y.^2))/(D_0_sq*D_0_sq));
z_2 = - D_0*sqrt(1-4*(x.^2 + y.^2)/D_0_sq).*(a_0 + a_1*(x.^2 + y.^2)/D_0_sq + ...
    (a_2*(x.^2 + y.^2).*(x.^2 + y.^2))/(D_0_sq*D_0_sq));
%D_0*sqrt(1-4*x_sq_y_sq/D_0_sq)*(a_0 + a_1*x_sq_y_sq/D_0_sq + (a_2*x_sq_y_sq*x_sq_y_sq)/(D_0_sq*D_0_sq));

% triangulation computation
dt = DelaunayTri(x,y,z);
dt_2 = DelaunayTri(x,y,z_2);
[tri Xb] = freeBoundary(dt);
[tri_2 Xb_2] = freeBoundary(dt_2);
% plot geometry
trisurf(tri,Xb(:,1),Xb(:,2),Xb(:,3), 'FaceColor', 'cyan', 'faceAlpha', 0.8);
hold on;
trisurf(tri_2,Xb_2(:,1),Xb_2(:,2),Xb_2(:,3), 'FaceColor', 'cyan', 'faceAlpha', 0.8);

提前谢谢!

1 个答案:

答案 0 :(得分:1)

正如评论中所写,你需要使用Delaunay三角测量的实数。因此,请不要忘记在此部分之前使用z = real(z)z_2 = real(z_2)

% triangulation computation
dt = DelaunayTri(x,y,z);
dt_2 = DelaunayTri(x,y,z_2);
[tri Xb] = freeBoundary(dt);
[tri_2 Xb_2] = freeBoundary(dt_2);
% plot geometry
trisurf(tri,Xb(:,1),Xb(:,2),Xb(:,3), 'FaceColor', 'cyan', 'faceAlpha', 0.8);
hold on;
trisurf(tri_2,Xb_2(:,1),Xb_2(:,2),Xb_2(:,3), 'FaceColor', 'cyan', 'faceAlpha', 0.8);