3D-Animation plot with the hgtransform command
Ältere Kommentare anzeigen
I continue to think of the possibilities for the 3d-animation (moving point along a curve). I have written the following code to try it using the hgtransform command but I do not understand why does not work.
t = 0:pi/50:10*pi;
x = sin(t);
y = cos(t);
z = t;
ah = axes;
set(ah,'XLim',[min(x) max(x)],'YLim',[min(y) max(y)],...
'ZLim',[min(z) max(z)]);
plot3(x,y,z,'Color','red');
hold on;
view(3);
hpoint = line('XData',x(1),'YData',y(1),'ZData',z(1),'Color','black','Marker',...
'o','MarkerSize',10,'MarkerFaceColor','black');
ht = hgtransform('parent',ah);
set(hpoint,'Parent',ht);
for i=2:length(x)
tx = x(i)-x(i-1);
ty = y(i)-y(i-1);
tz = z(i)-z(i-1);
trans = makehgtform('translate',[tx ty tz]),
set(ht,'Matrix',trans);
pause(0.01);
end
4 Kommentare
Walter Roberson
am 15 Jun. 2011
Looks plausible to me. What do you observe?
Julián Francisco
am 16 Jun. 2011
Walter Roberson
am 16 Jun. 2011
It rotates around for me. The only difficulty I observe is that the axis limits keep moving, shifting the plot back and forth.
Julián Francisco
am 18 Jun. 2011
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Animation finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!