how to change the dimension of ellipsoid after orientation

1 Ansicht (letzte 30 Tage)
ankit agrawal
ankit agrawal am 10 Aug. 2021
I have created an ellipsoid, plane and long axis line in step 1. Step 2 plane becomes horizontal to xy plane and ellispoid rotate along the plane. Now in step 3, I want to change the dimension of ellipsoid (fat ellipsoid along Z) but keep the orientation same something like hand drawn red ellipse in step 2. How should I achieve this? This is the code used to generate the following picture.
viewvector=[-68,18];
data=[1 1 0; -1, 1, 0; -1,-1,0; 1,-1,0];
longaxisline=[0,-2,0;0,2,0];
theta=120;
theta1=60;
direction = [1 0 0];
subplot(2,3,1))
[x,y,z]=ellipsoid(0,0,0,0.5,1,0.25,50);
h=surfl(x,y,z);
set(h,'facealpha',0.5)
shading interp
xlabel('x')
ylabel('y')
zlabel('z')
hold on
s=patch(data(:,1)',data(:,2)',data(:,3)') ;
rotate(s,direction,theta)
plot3(longaxisline(:,1),longaxisline(:,2),longaxisline(:,3),'b.-')
%s1=patch(data(:,1)',data(:,2)',data(:,3)');
axis image
view(viewvector)
%set(gca,'visible','off')
if j==1
title('step 1')
end
subplot(2,3,2)
h=surfl(x,y,z);
rotate(h,direction,theta)
set(h,'facealpha',0.5)
shading interp
xlabel('x')
ylabel('y')
zlabel('z')
hold on
s=patch(data(:,1)',data(:,2)',data(:,3)') ;
rotate(s,direction,0)
axis image
view(viewvector)
if j==1
title('step 2')
end
pp=longaxisline*RotationMatrix_X(theta1*pi/180); plot3(pp(:,1),pp(:,2),pp(:,3),'b.-')
%pp=longaxisline*RotationMatrix_Y(theta*pi/180); plot3(pp(:,1),pp(:,2),pp(:,3),'k-')
%pp=longaxisline*RotationMatrix_Z(theta*pi/180); plot3(pp(:,1),pp(:,2),pp(:,3),'r.-')
subplot(2,3,3)
[x,y,z]=ellipsoid(0,0,0,0.5,0.5,0.5,50);
%[x,y,z]=ellipsoid(0,0,0,0.5,1,0.25,50);
h=surf(x,y,z);
T = hgtransform('Parent',gca);
h.Parent=T;
T.Matrix=makehgtform('xrotate',theta*pi/180,'translate',[0 0 0]);
% h=surfl(x,y,z);
% rotate(h,direction,theta)
set(h,'facealpha',0.5)
shading interp
xlabel('x')
ylabel('y')
zlabel('z')
hold on
s=patch(data(:,1)',data(:,2)',data(:,3)') ;
rotate(s,direction,0)
axis image
view(viewvector)
if j==1
title('step 3')
end
pp=longaxisline*RotationMatrix_X(theta1*pi/180); plot3(pp(:,1),pp(:,2),pp(:,3),'b.-')

Antworten (0)

Kategorien

Mehr zu 3-D Scene Control finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by