How to Draw an Ellipse Flower like this?

조회 수: 2 (최근 30일)
Miguiussss
Miguiussss 2017년 1월 8일
댓글: Miguiussss 2017년 1월 8일
I need to draw 8 ellipses on the same grid and the angle of deviation between each of them must be pi/8. I have attached a flower with 18 leaves and I need to make one with 8 leaves. Each 'leave' is an ellipse.
Thanks in advance and greetings

채택된 답변

Image Analyst
Image Analyst 2017년 1월 8일
My attached demo does exactly that. Just adapt it to change the angle increment and center point.
  댓글 수: 4
Image Analyst
Image Analyst 2017년 1월 8일
I adapted it for you.
% Demo to rotate an ellipse over an image.
% By ImageAnalyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
hEllipse = imellipse(gca, [-5, -2, 5*2, 2*2]); % Second argument defines ellipse shape and position.
% Create a binary image ("mask") from the ROI object.
disp(hEllipse);
xy = hEllipse.getVertices();
x = xy(:,1);
y = xy(:,2);
xCenter = mean(x)
yCenter = mean(y)
plot(x, y);
axis equal;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
x = x - xCenter;
y = y - yCenter;
xy = [x y];
n = 8;
for theta = 0 : 180/n : 180 - 180/n
fprintf('Theta = %f\n', theta);
rotationArray = [cosd(theta) sind(theta); -sind(theta) cosd(theta)];
rotated_xy = xy * rotationArray;
x = rotated_xy(:,1);
y = rotated_xy(:,2);
plot(x, y, 'b-', 'LineWidth', 2);
hold on;
end
ax = gca
grid on;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
ax.XTick = -5:5
ax.YTick = -6:6
axis square;
Miguiussss
Miguiussss 2017년 1월 8일
Thank you so much my friend! I would not have been able to adapt it on my own. I apreciate you so much!!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by