How to solve explicit equation of ellipse

14 vues (au cours des 30 derniers jours)
cody Waldecker
cody Waldecker le 20 Oct 2020
Commenté : cody Waldecker le 20 Oct 2020
Hello,
I have the following equation:
(A*x^2)+(B*x*y)+(C*x)+(D*y^2)+(E*y)+F==0
Where all of the coefficients are already known and I am trying to find all values of x and y that satify the equation for the rotated ellipse. I cannot use fimplicit because it is not accurate enough, I need on the order of machine precision. I also tried to use solve(), but it only gives me two solutions for x and y. Do you guys know what other options I could try to solve this?
  2 commentaires
James Tursa
James Tursa le 20 Oct 2020
Modifié(e) : James Tursa le 20 Oct 2020
What do you mean you want "all values"? For an ellipse this is an infinite set. Do you mean you want the ellipse reoriented along principle axes? And you want to find the rotation? Or ...? Can you post some example sets of coefficients?
cody Waldecker
cody Waldecker le 20 Oct 2020
By all values, I mean the I would like enough to be able to accurately draw the ellipse if I needed to. I do not care about reorienting the ellipse or finding the rotation, I just would like to extract the exact values for x and y. However, I do understand that it may be necessary to rotate the ellipse back to the principal axis. Also, the coefficients are all fairly small for my situation, on the order of 10^-3.

Connectez-vous pour commenter.

Réponses (2)

Matt J
Matt J le 20 Oct 2020
If you convert the ellipse to its polar representation
that will give you an explicit formula with which to generate sample points.
  1 commentaire
cody Waldecker
cody Waldecker le 20 Oct 2020
Thank you for the reference

Connectez-vous pour commenter.


Bruno Luong
Bruno Luong le 20 Oct 2020
Modifié(e) : Bruno Luong le 20 Oct 2020
There is a function EllAlg2Geo ready to use in this FEX
% Random coefficients for test:
A = 0.5+rand;
D = 0.5+rand;
B = rand;
C = rand;
E = rand;
F = -rand;
H = [A, B/2;
B/2, D];
g = 0.5*[C; E];
c = F;
% FEX https://www.mathworks.com/matlabcentral/fileexchange/27711-euclidian-projection-on-ellipsoid-and-conic
[radii, U, x0] = EllAlg2Geo(H, g, c);
% points on ellipse, parametric
Ea = U*diag(radii);
theta = linspace(0,2*pi,181);
ellipse = x0 + Ea*[cos(theta); sin(theta)];
% implicit function on grid
[minxy, maxxy] = bounds(ellipse,2);
x = linspace(minxy(1),maxxy(1));
y = linspace(minxy(2),maxxy(2));
[X,Y] = meshgrid(x,y);
XY = [X(:) Y(:)]';
Z = reshape(sum(XY.*(H*XY + g),1) + c, size(X)); % == (A*x^2)+(B*x*y)+(C*x)+(D*y^2)+(E*y)+F
Z = reshape(Z, size(X));
figure
imagesc(x,y,Z);
hold on
% implicit curve
% contour(x,y,Z,[0 0],'ro'); % gives also points on ellipse
plot(ellipse(1,:),ellipse(2,:),'w');
axis equal;

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by