Making ellipse keep the signed distance function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Please, can someone help me: I want to use signed-distance function for ellipse. That means the contours must be equal distance from each other. But the distances are currently not equal. The matlab code is below. Thank you so much.
DomainWidth=2;
DomainHight=1;
ENPC=80;
ENPR=160;
EW = DomainWidth / ENPR; % The width of each finite element.
EH = DomainHight / ENPC; % The hight of each finite element.
M = [ ENPC + 1 , ENPR + 1 ];
[ x,y ] = meshgrid( EW * [ -0.5 : ENPR + 0.5 ] , EH * [ -0.5 : ENPC + 0.5 ]);
[ FENd.x, FENd.y, FirstNdPCol] = MakeNodes(ENPR,ENPC,EW,EH);
LSgrid.x = x(:); LSgrid.y = y(:); % The coordinates of Level Set grid 1
%%Generate ellipse
cx = DomainWidth/2;
cy= DomainHight/2;
tmpPhi= ( (LSgrid . x - cx)/cx ) .^2 + (( LSgrid . y - cy)/(cy) ) .^2 - 1;
LSgrid.Phi = -((tmpPhi.')).';
FENd.Phi = griddata( LSgrid.x, LSgrid.y, LSgrid.Phi, FENd.x, FENd.y, 'cubic');
figure(10)
% % subplot(2,1,1)
contourf( reshape( FENd.x, M), reshape(FENd.y , M), reshape(FENd.Phi, M));
axis equal; grid on;colorbar;drawnow;
% colorbar;
figure(11)
h3=surface(x, y, reshape(LSgrid.Phi , M + 1)); view([37.5 30]); axis equal; grid on;
set(h3,'FaceLighting','phong','FaceColor','interp', 'AmbientStrength',0.6); light('Position',[0 0 1],'Style','infinite'); colorbar;
%%Code for creating nodes
function [NodesX, NodesY, FirstNdPCol] = MakeNodes(EleNumPerRow,EleNumPerCol,EleWidth,EleHight)
[ x , y ]= meshgrid( EleWidth * [ 0 : EleNumPerRow ], EleHight * [0 : EleNumPerCol]);
FirstNdPCol = find( y(:) == max(y(:)));
NodesX = x(:); NodesY = y(:);
end
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Contour Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!