Rotating images after creating an image
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Image Analyst
2013 年 6 月 15 日
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 件のコメント
Image Analyst
2013 年 6 月 15 日
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
2013 年 6 月 15 日
編集済み: sam
2013 年 6 月 15 日
1 件のコメント
Image Analyst
2013 年 6 月 15 日
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.
参考
カテゴリ
Help Center および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!