# Equation of ellipse given one axis and another point

I'm trying to find the equation of a general ellipse given 3 points. Two of those points should be at each end of one axis. Using this I have the center of the ellipse, and the angle of rotation with respect to the x-axis that this axis is rotated. It's unknown whether this is the major or minor axis. The third point is given which can be anywhere on the ellipse. The only other thing to find is the other axis.

This is my attempt. Phi is the angle of rotation of the given mystery axis and abtemp is its size. X(3),Y(3) is the third point. The first equation assumes that the given axis is the major axis and the second assumes it is the minor axis. The problem is that for some of these near 400 ellipses I get negative and imaginary values for the other axes. I'm not sure what's going on here.

tb1 = (-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/sqrt(1-((X(3)*cos(phi)+Y(3)*sin(phi) Xcenter)/abtemp)^2);

ta1 = (X(3)*cos(phi)+Y(3)*sin(phi)-Xcenter)/sqrt(1-((-X(3)*sin(phi)+Y(3)*cos(phi)-Ycenter)/abtemp)^2);

Ok, well the sometimes negative values are obviously because of the taking of the square root so the absolute value should be used. I'm still getting what seem to be very incorrect answers. To expand this is how I find the length of the given axis where X(1),Y(1) and X(2),Y(2) are the vertices of the given axis:

abtemp = sqrt((X(2)-X(1))^2+(Y(2)-Y(1))^2)/2;

The center:

Xcenter = (X(1)+X(2))/2;
Ycenter = (Y(1)+Y(2))/2;

And the angle:

Last edited:
Simon Bridge
Homework Helper
Lets see if I understand:

You are given three points P1, P2, and P3.
They are at positions ##Pn: \vec r_n=(x_n,y_n)^t:n=1,2,3## ... so all the points are in the same plane.

You also know the standard form for a conic section in a plane - so you can plug the numbers in and solve the simultaneous equations ... using the extra info (ellipse, two points on a principle axis) to help with the solution.

But: You hope for a shortcut by using the extra information at the start - which is fair enough.

From your approach, I am guessing that you are told which of the three points are on the axis, but not which axis it is. Your strategy is to align the coordinate system to the ellipse and exploit a simplified general form for the ellipse equation - then use the inverse transform to get the actual equation?

Just call the semi-axis ##a## - saves typing.
If the first two points are on the axis, then ##a## is half the modulus of the vector difference between their positions. $$2a=|\vec r_{1,2}|=|\vec r_2-\vec r_1|=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}$$ ... which you got.

The vector ##\vec r_{1,2}## is the vector pointing from P1 to P2 and it is very useful.
For instance: the angle to the x-axis will just be the argument of ##\vec r_{1,2}## and the center is at ##\vec r_c= \vec r_1 + \frac{1}{2}\vec r_{1,2}##
you did it a different way ... but I don't see any glaring problems. OTOH: I'm not sure I follow your notation either. It sometimes helps to check your answers by applying a different approach.

NOte: it is possible, from the general equation, to get an imaginary ellipse.
http://en.wikipedia.org/wiki/Matrix_representation_of_conic_sections

You can safely eliminate ellipses with negative or imaginary values for properties which, by definition, must be positive and real. The general equations will probably include objects that are not your ellipse: there is more than one shape that could pass through all three points.

You can probably look up the general form of the ellipse with semi-axis ##a## and ##b##, center at ##\vec r_c=(x_0,y_0)## and tilted by angle ##\theta## to the x-axis. Then it's just a matter of plugging the numbers in.

Last edited:
Thanks for the response. I already have the values you mention. I have one axis, the center, and the angle of rotation of that axis with respect to the x-axis. This only leaves one unknown. The general equation for a rotated and translated ellipse is:

((X*cos(phi)+Y*sin(phi)-Xcenter)/a)^2+((Y*cos(phi)-X*sin(phi)-Ycenter)/b)^2 = 1

I've also attempted to plug in for X and Y my third point which is not connected to an axis. Assume the given axis is for instance the major axis, and iterate values for the minor axis until I find which value gives the closest result to 1. If I assumed incorrectly about which axis the given axis actually is it never gets close to one and I then do the same assuming it is the other. I am able to do this seemingly successfully but the resulting ellipse does not overlap any of the points which doesn't make any sense!

I must be understanding something wrong about the angle or calculating something incorrectly. Either of the methods I've tried should work.

Last edited:
Simon Bridge
Homework Helper
((X*cos(phi)+Y*sin(phi)-Xcenter)/a)^2+((Y*cos(phi)-X*sin(phi)-Ycenter)/b)^2 = 1

um - that would be... $$\left(\frac{x\cos\phi + y\sin\phi - x_0}{a}\right)^2+\left(\frac{x\cos\phi - y\sin\phi - y_0}{b}\right)^2=1$$
... the main thing to check is if this formula rotates the coordinate axis or the ellipse itself.
Rotating the ellipse by ##\phi## is the same as rotating the axis by ##-\phi##.

I already have the values you mention. I have one axis, the center, and the angle of rotation of that axis with respect to the x-axis. This only leaves one unknown.
Plug the third point into the ellipse and solve for the other axis.

Last edited:
Simon Bridge
Homework Helper
Worked example:

##P1:\vec r_1=(1,2),\; P2:\vec r_2=(4,6),\; P3:\vec r_3=(3,2)##

Told that ##P1## and ##P2## are on an axis.$$\vec r_{12}=\vec r_2-\vec r_1=(3,4)\\ d=\frac{1}{2}|\vec r_{12}|=2.5$$ ... where d is the semi-length of the axis: this axis is rotated so that: ##\sin\theta = 0.8##, ##\cos\theta = 0.6##

i.e. ##\theta=53.13^\circ## antclockwise from the x axis.
Note: this is the current orientation of the axis - not the amount it has been rotated.

The center is at ##\vec r_c= r_1 + \frac{1}{2}r_{12}=(2.5,4)##

In standard orientation, the a axis is aligned with the x axis ... so the rotation angle is ##\phi=\theta##

$$\left(\frac{(3/5)x + (4/5)y - 2.5}{2.5}\right)^2+\left(\frac{(3/5)x - (4/5)y - 4}{b}\right)^2=1 \\ \Leftrightarrow \left(\frac{6x + 8y - 25}{25}\right)^2+\left(\frac{3x - 4y - 20}{5b}\right)^2=1$$ ... plug in P3 and solve for b.

But what if I'd guessed that the axis is the b axis:
In standard position, the b axis is aligned at ##\theta=+90^\circ## to the x-axis.
That means it must have been rotated ##\phi=90-\theta## clockwise...

Three points should uniquely describe the ellipse in question.
Therefore, one of these two approaches should give nonsense.
Sketch the points out to check - see which orientation makes sense.

Note: does it matter if a is the semi-major axis or not?