Plot a moving wheel in the 3D space

조회 수: 7 (최근 30일)
Gregory Cottone
Gregory Cottone 2021년 7월 25일
댓글: darova 2021년 7월 30일
Hi,
I need to plot a wheel moving in the 3D space, for example a rolling wheel in a circumferential trajectory, could someone help me to do this?
Thank you all in advance,
Gregory

답변 (1개)

darova
darova 2021년 7월 26일
% create model
t = linspace(0,2*pi,10);
[x,y] = pol2cart(t,1);
X = [y*0;y*0;y*0+2;y*0+2];
Y = [y*0;y;y;y*0];
Z = [x*0;x;x;x*0];
h1 = surf(X,Y,Z); % closed cylinder
[x0,y0] = meshgrid(-1:3,-1:10);
h2 = surface(x0,y0,x0*0-1); % plate
% animte
axis equal
for i = 1:10
rotate(h1,[1 0 0],pi/10,[0 0 0])% rotate wheel
y1 = get(h2,'ydata');
set(h2,'ydata', y1-pi/10) %move plate
pause(0.5)
end
  댓글 수: 2
Gregory Cottone
Gregory Cottone 2021년 7월 30일
Dear Darova,
thank you for the answer, the wheel seems to go ahead, but what I need is a wheel able to follow a curvilinear trajectory, in particular, in your script the rotation axis is always oriented along global x-axis, but I need a wheel with rotation axis changing orientation during the animation.
Thank you in advance and best regards,
Gregory
darova
darova 2021년 7월 30일
Here is
t = 0:.1:50; % wheel velocity
p = pi/4+t/30; % angular velocity around Z axis
x = (t+cos(-t)) .* cos(p);
y = (t+cos(-t)) .* sin(p);
z = 1 + sin(-t);
surf([x;x],[y;y],[z;z-.3])
% view(90,90)
xlabel('x')
ylabel('y')
light
axis equal

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by