I am trying to visualise 3d red blood cell geometry with the following function.
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)
I want to random distribute the point on the geometry and then using the triangulation function to visualise it. below is my matlab code I have written. There is something wrong with my points' set up.I couldnt get idea result, I think the problem is that I don't know how to choose the x,y parameter range.
% 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);
Thank you in advance!
Well as written in the comments, you need to use real numbers with Delaunay triangulation. So don't forget to use z = real(z)
and z_2 = real(z_2)
before this part:
% 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);