how to draw a ellipse with known its general equation

7 ビュー (過去 30 日間)
UTA
UTA 2012 年 9 月 3 日
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 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 3 日
you said to set x=1:1:1000 this is not possible because x is a solution of your equation
Walter Roberson
Walter Roberson 2012 年 9 月 4 日
UTA does not want to set x values and find the corresponding y values: UTA hopes for a parametric solution.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 9 月 4 日

Image Analyst
Image Analyst 2012 年 9 月 4 日
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]);

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by