What is the general equation of the ellipse that is not in the origin and rotated by an angle?

After a lot of mistakes I finally got the correct equation for my problem:-

$$\dfrac {((x-h)\cos(A)+(y-k)\sin(A))^2}{a^2}+\dfrac{((x-h) \sin(A)-(y-k) \cos(A))^2}{b^2}=1,$$

where $h, k$ and $a, b$ are the shifts and semi-axis in the $x$ and $y$ directions respectively and $A$ is the angle measured from $x$ axis.


The equation you gave can be converted to the parametric form: $$ x = h + a\cos\theta \quad ; \quad y = k + b\sin\theta $$ If we let $\mathbf x_0 = (h,k)$ denote the center, then this can also be written as $$ \mathbf x = \mathbf x_0 + (a\cos\theta)\mathbf e_1 + (b\sin\theta)\mathbf e_2 $$ where $\mathbf e_1 = (1,0)$ and $\mathbf e_2 = (0,1)$.

To rotate this curve, choose a pair of mutually orthogonal unit vectors $\mathbf u$ and $\mathbf v$, and then $$ \mathbf x = \mathbf x_0 + (a\cos\theta)\mathbf u + (b\sin\theta)\mathbf v $$ One way to define the $\mathbf u$ and $\mathbf v$ is: $$ \mathbf u = (\cos\alpha, \sin\alpha) \quad ; \quad \mathbf v = (-\sin\alpha, \cos\alpha) $$ This will give you an ellipse that's rotated by an angle $\alpha$, with center still at the point $\mathbf x_0 = (h,k)$.

If you prefer an implicit equation, rather than parametric ones, then any rotated ellipse (or, indeed, any rotated conic section curve) can be represented by a general second-degree equation of the form $$ ax^2 + by^2 + cxy + dx + ey + f = 0 $$ The problem with this, though, is that the geometric meaning of the coefficients $a$, $b$, $c$, $d$, $e$, $f$ is not very clear.

There are further details on this page.

Addition. Borrowing from rschwieb's solution ...

Since you seem to want a single implicit equation, proceed as follows. Let $c = \sqrt{a^2 - b^2}$. Then the foci of the rotated ellipse are at $\mathbf x_0 + c \mathbf u$ and $\mathbf x_0 - c \mathbf u$. Using the "pins and string" definition of an ellipse, which is described here, its equation is $$ \Vert\mathbf x - (\mathbf x_0 + c \mathbf u)\Vert + \Vert\mathbf x - (\mathbf x_0 - c \mathbf u)\Vert = \text{constant} $$ This is equivalent to the one given by rschwieb. If you plug $\mathbf u = (\cos\alpha, \sin\alpha)$ into this, and expand everything, you'll get a single implicit equation.

The details are messy (which is probably why no-one wants to actually write everything out for you).


Another option is to use the geometric definition of an ellipse as the set of points whose sum distance to the foci is constant.

If the foci are at $(a,b)$ and $(a',b')$, and the sum distance is $C$, you get:

$$\sqrt{(x-a)^2+(y-b)^2}+\sqrt{(x-a')^2+(y-b')^2}=C$$


If you came here looking for how $$c_0x^2 + c_1y^2 + c_2xy + c_3x + c_4y + c_5 = 0$$ relates to $h, k, a, b, A$ its the following: \begin{eqnarray} c_0&=&\frac{\cos^2(A)}{a^2} + \frac{\sin^2(A)}{b^2}\\ c_1&=&\frac{\sin^2(A)}{a^2} + \frac{\cos^2(A)}{b^2}\\ c_2&=&\frac{\sin(2A)}{a^2} - \frac{\sin(2A)}{b^2}\\ c_3&=&-\frac{2 h \cos^2(A)}{a^2} - \frac{k\sin(2A)}{a^2} - \frac{2 h \sin^2(A)}{b^2} + \frac{k \sin(2A)}{b^2}\\ c_4&=&-\frac{h \sin(2A)}{a^2} - \frac{2k\sin^2(A)}{a^2} + \frac{h \sin(2A)}{b^2} - \frac{2k \cos^2(A)}{b^2}\\ \end{eqnarray} $$c_5 = \frac{h^2 \cos^2(A)}{a^2} + \frac{h k \sin(2A)}{a^2} + \frac{k^2 \sin^2(A)}{a^2} + \frac{h^2 \sin^2(A)}{b^2} - \frac{ h k \sin(2A)}{b^2} + \frac{k^2 \cos^2(A)}{b^2} - 1 $$