matlab - Why the rotation doesn't work in this code -
my problem rotate ellipsoid model around origin. i'm using rotation matrices answer doesn't ok. can tell me problem is? below code. 1st defined region , grid size. alpha, beta, gamma rotations around x,y,z axis. calculate ellipsoid radii's in new coordinate (rotated coordinate) check point point if agree ellipsoid formula define epsilon matrix goal based on points locations. @ end plot epsilon matrix xy,xz,yz planes. works alpha,beta,theta =0 , 90 degrees other angles there's not resealable answer. think mistake?
fyi: code part of fdtd method maxwell's equations solver.
thanks,
nx=209; ny=209; nz=209; x_lower=1 ; y_lower=1 ; z_lower=1 ; x_upper=nx ; y_upper=ny ; z_upper=nz ; dz=2.366863905325444e-008 ; dy=2.366863905325444e-008 ; dx=2.366863905325444e-008 ; k_mid=(nz+1-1)/2+1; j_mid=(ny+1-1)/2+1; i_mid=(nx+1-1)/2+1; x_cyto=0 ; y_cyto=0 ; z_cyto=0 ; r_cell=2e-6; alpha=0; beta=0; gamma=0; temp_1=1.334 ; temp_2=1.35; a_cyto=1e-6 ; b_cyto=1e-6 ; c_cyto=1e-6 ; temp_3=1.39; a_nucl=1e-6 ; b_nucl=1.5e-6 ; c_nucl=1e-6 ; x_nucl=0 ; y_nucl=0 ; z_nucl=0 ; a_cyto_prime=(a_cyto*(cosd(beta)*cosd(gamma)))-(b_cyto*(cosd(beta)*sind(gamma)))+(c_cyto*(sind(beta))); b_cyto_prime=(a_cyto*((sind(alpha)*sind(beta)*cosd(gamma))+(cosd(alpha)*sind(gamma))))+... (b_cyto*(-(sind(alpha)*sind(beta)*sind(gamma))+(cosd(alpha)*cosd(gamma))))+... (c_cyto*(-sind(alpha)*cosd(beta))); c_cyto_prime=(a_cyto*(-(cosd(alpha)*sind(beta)*cosd(gamma))+(sind(alpha)*sind(gamma))))+... (b_cyto*(+(cosd(alpha)*sind(beta)*sind(gamma))+(sind(alpha)*cosd(gamma))))+... (c_cyto*(cosd(alpha)*cosd(beta))); k=z_lower:z_upper z=dz*(k-k_mid); z2=(z-z_cyto)^2; j=y_lower:y_upper y=dy*(j-j_mid); y2=(y-y_cyto)^2; i=x_lower:x_upper x=dx*(i-i_mid); x2=(x-x_cyto)^2; if (x2*b_cyto_prime*b_cyto_prime*c_cyto_prime*c_cyto_prime)+... (y2*a_cyto_prime*a_cyto_prime*c_cyto_prime*c_cyto_prime)+... (z2*a_cyto_prime*a_cyto_prime*b_cyto_prime*b_cyto_prime)<=... (a_cyto_prime*a_cyto_prime*b_cyto_prime*b_cyto_prime*c_cyto_prime*c_cyto_prime) epsilon(i,j,k)=temp_2; mu(i,j,k)=1; % if (sqrt(x2+y2+z2)>=r_cell) % epsilon(i,j,k)=temp_1; % mu(i,j,k)=1; % else % epsilon(i,j,k)=temp_2; % mu(i,j,k)=1; % end else epsilon(i,j,k)=temp_1; mu(i,j,k)=1; end end end end eps_2d_yz(1:x,1:x)=epsilon(round(x/2),:,:); eps_2d_xz(1:x,1:x)=epsilon(:,round(x/2),:); eps_2d_xy(1:x,1:x)=epsilon(:,:,round(x/2)); x=length(eps_2d_xy); subplot(1,3,1); surf(-round((x-1)/2):round((x-1)/2),-round((x-1)/2):round((x-1)/2),eps_2d_xy); title('xy'); view(2); axis equal tight; subplot(1,3,2); surf(-round((x-1)/2):round((x-1)/2),-round((x-1)/2):round((x-1)/2),eps_2d_xz); title('xz'); view(2); axis equal tight; subplot(1,3,3); surf(-round((x-1)/2):round((x-1)/2),-round((x-1)/2):round((x-1)/2),eps_2d_yz); title('yz'); view(2); axis equal tight;
Comments
Post a Comment