Problem with the rotated object shape
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I have written a code for generating egg shape from ellipse using the model explained in the link below optimal shape of avian egg.The ellipse that i have generated is using normal parametric equations. x = a*cos(theta) y = b* sin(theta) Below is the figure of ellipse along with the egg shape generated by the model explained in the link above.
</matlabcentral/answers/uploaded_files/57944/ellipse%20and%20egg%20shape.jpg> next I tried to rotate the egg shape by angle pi/2 using transformation matrix; but this is what i get.
</matlabcentral/answers/uploaded_files/57945/rotated%20egg%20shape.jpg> My question is why am I not getting a proper egg shape in the rotated version?I get proper figure for an angle of pi.but not for any other angles .... pi/6,pi/3 etc....
0 comentarios
Respuestas (1)
  KSSV
      
      
 el 17 de Ag. de 2016
        I don't know how you have rotated the object/ geometry; I cannot even open the links you have given. You may consider the below code, which may help you.
clc; clear all ;
 s = [-1 -1 ; -1 1 ; 1 1 ; 1 -1 ; -1 -1]' ;  % draw square
 plot(s(1,:),s(2,:),'r') ;
 %%rotate the object 
 th = pi/4 ;   % rotate by 45 degrees
 R = [cos(th) -sin(th) ; sin(th) cos(th)] ;  % rotation matrix 
 S = zeros(size(s)) ;   % initialize rotated coordinates 
 for i = 1:size(s,2)
     S(:,i) = R*s(:,i) ;
 end
 hold on
 plot(S(1,:),S(2,:),'b') ;
6 comentarios
  William Chamberlain
 el 3 de Oct. de 2018
				
      Editada: William Chamberlain
 el 3 de Oct. de 2018
  
			Add
axis equal
at the end? And use
   xlim( [] )  ;  ylim( [] )  ;
to control the axes extent.
Ver también
Categorías
				Más información sobre Interactions, Camera Views, and Lighting en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


