MATLAB: How to determine a set of points which belong to an equation

conic sectionsquadrics

Given the general equation of a conic section:
P(x,y) = Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0
and knowing the coefficients {A,B,C,D,E,F}, how do I determine a set of points that belong to the curve represented in the equation?
I don't know if it helps, but I already know this is an ellipse.
Thank You.

Best Answer

I suppose one could choose any arbitrary value for x, substitute them into the equation, then use the quadratic formula to determine the TWO solutions for y. If no real solutions exist, then x is outside the region where a solution can exist. You can get a bit more sophisticated, and figure out the center of the ellipse and the limits in x.
More intelligently, one can transform the ellipse into a standard mathematical form. Perhaps something like this:
(X - X0)'*H*(X - X0) = 1
Here X and X0 are column vectors (of shape 2x1), and H is a 2x2 matrix. X0 defines the center of the ellipse. H defines the orientation of the major and minor axes, as well as the lengths of those axes.
H will be a positive semi-definite matrix (if these coefficients truly define an ellipse.) We can then compute the eigenvalue decomposition of X. Use eig for that. It will be of the general form:
H = V'*D*V
So then we have
(X - X0)'*V'*D*V*(X - X0) = 1
This would allow you to implicitly transform the ellipse into a circle. So now one would generate points on a unit circle (trivial) then transform THOSE points into the ellipse.
Or, if your goal is a simple one, and all you want is a plot, then be lazy. This would work:
ezplot(@(x,y) 2*x.^2 + 3*y.^2 - 2.5*x.*y + x - y - 15)
(Myself, I'm feeling too lazy to migrate in the figure it generates.)
Anyway, IF you were incredibly lazy, then you could extract the generated set of points made by ezplot from the figure, IF you truly wanted a set of points in the end too.
Since you were pretty vague about what you wanted from that set of points, I can't really know which of the above approaches one would best choose. Any of them will suffice.