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!