Rotating images after creating an image
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Make a function e91.m, that takes 2 arguments, and is called like this:
e91(a, rotRad);
it should make a movie of a disk that has area a, and is rotating around in the figure. The disk should rotate around the centre of the figure, at a distance rotRad from the centre. The function should play this video 10 times.
This has taken me about 2 hours to do. ive tried my best but i have so many mistakes! Any help would be appreciated!
cheers, i always make typos!
Have i made any huge fundamental mistakes?
clc;
[x,y] = meshgrid(-200:200);
r = 50;
cx = 200;
cy = 200;
circleImage = (x-cx).^2 + (y-cy).^2 < r^2;
imagesc(x(:,1),y(:,1),circleImage);
colormap(gray);
axis square;
xlim([-200, 200]);
ylim([-200, 200]);
axis on;
frameNumber = 1;
for angleInDegrees = 1:10:360 % Degrees
cx = 200 * cosd(angleInDegrees)
cy = 200 * sind(angleInDegrees)
circleImage = (x-cx).^2 + (y-cy).^2 < r^2;
imagesc(circleImage);
% mov(frameNumber) = getframe;
frameNumber = frameNumber + 1;
drawnow;
pause(0.2);
end
% movie(mov,10);
0 comentarios
Respuestas (2)
Image Analyst
el 15 de Jun. de 2013
Close, but this will get you a little closer without doing everything for you. Did you notice that cx, not cy, was being subtracted from your y? And it's better to have a loop over angle like I did it.
clc;
[x,y] = meshgrid(-200:200);
r = 50;
cx = 200;
cy = 200;
circleImage = (x-cx).^2 + (y-cx).^2 < r^2;
imagesc(x(:,1),y(:,1),circleImage);
colormap(gray);
axis square;
xlim([-200, 200]);
ylim([-200, 200]);
axis on;
frameNumber = 1;
for angleInDegrees = 1:10:360 % Degrees
cx = 200 * cosd(angleInDegrees)
cy = 200 * sind(angleInDegrees)
circleImage = (x-cx).^2 + (y-cy).^2 < r^2;
imagesc(circleImage);
% mov(frameNumber) = getframe;
frameNumber = frameNumber + 1;
drawnow;
pause(0.2);
end
% movie(mov,10);
Don't worry - there's still more for you to do and fix.
1 comentario
Image Analyst
el 15 de Jun. de 2013
Regarding your edit. I don't feel like you're putting enough effort into your homework. I gave you that code, which does almost everything (it spins a circle around the image) and asked you to finish it but you didn't do anything except paste my code into your original question. Don't expect us to do everything for you, or else you wouldn't be handing in your solution, you'd be handing in ours. It's your homework so you must do some of it, probably the majority of it, not us.
sam
el 15 de Jun. de 2013
Editada: sam
el 15 de Jun. de 2013
1 comentario
Image Analyst
el 15 de Jun. de 2013
cx and cy are the radius of the circle about which the circle moves. "r" is the radius of the circle itself - the white disc that moves.
Ver también
Categorías
Más información sobre Graphics Performance 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!