how to draw a ellipse with known its general equation

12 views (last 30 days)
I want to draw a ellipse with known its general form of equation as follow form:
a*x^2 + b*x*y + c*y^2 +d*x + e*y + f = 0
where a b c d e f are the parameters of above equation.
Here, I want convert the general equation to Parametric equations and then draw it. If you can directly draw it without convert, I also accept it , however, I just do not hope to set the step for x as 1:1:1000 to get another value of y or vice versa. Is anybody can help me, thanks ahead!
  2 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 3 Sep 2012
you said to set x=1:1:1000 this is not possible because x is a solution of your equation
Walter Roberson
Walter Roberson on 4 Sep 2012
UTA does not want to set x values and find the corresponding y values: UTA hopes for a parametric solution.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 4 Sep 2012

Image Analyst
Image Analyst on 4 Sep 2012
Try my demo:
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
clearvars;
format longg;
format compact;
fontSize = 20;
% Parameterize the equation.
t = linspace(0, 360,1000);
phaseShift = 20;
xAmplitude = 2;
yAmplitude = 1;
x = xAmplitude * sind(t + phaseShift);
y = yAmplitude * cosd(t);
% Now plot the rotated ellipse.
plot(x, y, 'b-', 'LineWidth', 2);
axis equal
grid on;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
title('Rotated Ellipses', 'FontSize', fontSize);
text(-1.75, 1.4, 'Parametric --', 'Color', 'b', 'FontSize', fontSize);
% Now plot another ellipse and multiply it by a rotation matrix.
% http://www.maa.org/joma/Volume8/Kalman/General.html
rotationAngle = 30;
transformMatrix = [cosd(rotationAngle), sind(rotationAngle);...
-sind(rotationAngle), cosd(rotationAngle)]
xAligned = xAmplitude * sind(t);
yAligned = yAmplitude * cosd(t);
xyAligned = [xAligned; yAligned]';
xyRotated = xyAligned * transformMatrix;
xRotated = xyRotated(:, 1);
yRotated = xyRotated(:, 2);
hold on;
plot(xRotated, yRotated, 'g-', 'LineWidth', 2);
% Plot a line at 30 degrees
slope = tand(30);
x1 = min(x(:));
y1 = slope * x1;
x2 = max(x(:));
y2 = slope * x2;
line([x1 x2], [y1 y2], 'Color', 'r');
text(-1.75, 1.25, 'Rotation Matrix --', 'Color', 'g', 'FontSize', fontSize);
text(-1.75, 1.1, '30 Degree Line --', 'Color', 'r', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);

Tags

Community Treasure Hunt

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

Start Hunting!