Rotate a 2D function regarding Z-axis (Matlab script)
Código de Matlab:
% Rotate a 2D function with respect z-axis
x = -10:0.01:10;
y = 3*cos(4*x);
v = [x(:) y(:)];
% theta is in radians (2*pi is equivalent to 360 degrees)
for theta = 0:0.01:2*pi
% Matrix rotation wit respect z-axis order: 2 x 2
R = [cos(theta) -sin(theta); sin(theta) cos(theta)];
% Multiply the matrix v x R (to rotate all the 2D space)
... v is N x 2 order and R is 2 x 2 order then
... vr is of N x 2 order
vr = v*R;
x = vr(:,1);
y = vr(:,2);
plot(x,y,'Linewidth',4);
axis([-15 15 -15 15]);
pause(0.01);
end
Video: https://youtu.be/Et3fGNrPprM
Comentarios
Publicar un comentario