I'm trying to plot the vertices of an ellipse of the form:
$Ax^2 + Bxy + Cy^2 + Dx + Ey + F = 0$.
Here's my attempt:
A = -0.009462052409440;
B = 0.132811666715687;
C = -0.991096125887092;
D = 1.450474988439371;
E = -10.108254824293347;
F = -55.282226665842030;
% semi-major axis
a = -sqrt(2(AE^2 + CD^2 - BDE + (B^2 - 4AC)F)((A+C) + sqrt((A-C)^2 + B^2)))/(B^2-4A*C); % semi-major
% semi-minor axis
b = -sqrt(2(AE^2 + CD^2 - BDE + (B^2 - 4AC)F)((A+C) - sqrt((A-C)^2 + B^2)))/(B^2-4A*C); % semi-minor
% centre of ellipse
xx = (2CD -BE)/(B^2-4AC);
yy = (2AE - BD)/(B^2-4AC);
% the angle from the positive horizontal axis to the ellipse's major axis
if B ~= 0
theta = atan(1/B*(C-A-sqrt((A-C)^2 + B^2)));
elseif A < C
theta = 0;
else
theta = pi/2;
end
% plot ellipse
fimplicit(@(x,y) Ax.^2 +Bx.y + Cy.^2 + Dx + Ey + F,'--')
xlim([68,86])
ylim([-1,1])
% plot centre point
hold on
plot(xx,yy,'rx')
% plot vertices
plot(xx + acos(theta),yy + asin(theta),'rx')
plot(xx + acos(-theta),yy + asin(-theta),'rx')
plot(xx + bcos(theta+pi/2),yy + bsin(theta+pi/2),'rx')
plot(xx + bcos(theta-pi/2),yy + bsin(theta-pi/2),'rx')
Result:
Clearly something is not quite right, but I can't seem to figure it out.
The formulae for axes and angle are taken from here: https://en.wikipedia.org/wiki/Ellipse#General_ellipse
The ellipse needs to remain in its original form, so no transformations or rotations in the final result please.


pbaspectin MATLAB and it seems like the ratio is already 1:1. I think you're right though, it does appear to be a visual issue.Do you know how I can get it to look correct without it looking stretched?
– CanofDrink Jul 10 '20 at 13:57daspect([1 1 1])makes the points look like they're in the correct position, but the plot now looks stretched similar to yours which isn't ideal as I need to fit a bunch of lines and annotations. – CanofDrink Jul 10 '20 at 14:06