How to Draw an Ellipse Flower like this?

2 visualizaciones (últimos 30 días)
Miguiussss
Miguiussss el 8 de En. de 2017
Comentada: Miguiussss el 8 de En. de 2017
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

Respuesta aceptada

Image Analyst
Image Analyst el 8 de En. de 2017
My attached demo does exactly that. Just adapt it to change the angle increment and center point.
  4 comentarios
Image Analyst
Image Analyst el 8 de En. de 2017
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 el 8 de En. de 2017
Thank you so much my friend! I would not have been able to adapt it on my own. I apreciate you so much!!!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by