Given an ellipse centred at the origin with major and minor axes and slope of the major axis specified:
rotated ellipse

How can I convert those three parameters into parameters that would express a scaled and sheared ellipse at the origin?
sheared ellipse

What I need is the width and height of the green parallelogram and the slope of the blue line when the red line is lying flat.

I might also be interested in versions with angles rather than slopes. I'm assuming it's easier with slopes but I could be wrong.

(I only have maybe highschool level maths so please excuse my ignorance of proper terminology. The images are not mine, just "close enough" ones I found on the net, the angles should actually match. I hope they are clear enough.)

Proposed rewording by @Blue.

A rotated ellipse can be interpreted as a (horizontally-)sheared ellipse. For instance, "an ellipse with radii $a$ and $b$, transformed by rotation through angle $\theta$" is just as well described as "an ellipse with radii $p$ and $q$, transformed by (horizontal) shear of angle $\phi$".

enter image description hereenter image description here

I want to know how to convert from one set of parameters to the other. That is,

$$\text{Given $a$, $b$, $\theta$, what are $p$, $q$, $\phi$?}$$

  • It may be easier to express the amount of rotation and shear as slopes rather than angles.
  • For the shear, I'm more interested the height of the bounding parallelogram ($q$ in the figure) not the transformed radius ($q^\prime$). (Of course, these are related by $q = q^\prime \sin\phi$.)
  • $\begingroup$ A sheared ellipse is still a rotated ellipse because shearing is a linear transform that does not change the degree of a curve, which is $2$ for an ellipse. $\endgroup$
    – Zhuoran He
    Nov 8, 2017 at 5:15
  • 1
    $\begingroup$ Yes exactly. I know any ellipse can be expressed both ways but I don't have enough math to know how to convert the parameters from the former to the latter. Apologies if my wording is unclear. $\endgroup$ Nov 8, 2017 at 5:17
  • $\begingroup$ Which $3$ parameters are you referring to? $\endgroup$
    – user99914
    Nov 8, 2017 at 5:25
  • 1
    $\begingroup$ @JohnMa: Input parameters are 1) length of major axis, 2) length of minor axis, 3) slope of major axis. Output parameters are 1) width of bounding parallelogram aligned to the x-axis, 2) height of bounding parallelgram (on the y axis, not the length of the diagonal green line), 3) slope of the diagonal green line. $\endgroup$ Nov 8, 2017 at 5:30
  • 1
    $\begingroup$ @hippietrail: You're welcome. :) ... I guess I was working on my images while the answers were in flight. I agree that the color references are important. I think you can leave things as-is. $\endgroup$
    – Blue
    Nov 8, 2017 at 6:51

2 Answers 2


Recall that the standard form of an ellipse centered at the origin is $$\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1,$$ where $a$ is half the length of the horizontal axis and $b$ half the vertical (so we only need $a, b > 0$ and there is no need to specify $a > b$). Upon counterclockwise rotation by an angle $\theta$ about the origin, that is to say, $$(x,y) \to (x \cos \theta - y \sin \theta, x \sin \theta + y \cos \theta),$$ this equation takes the form $$Ax^2 + Bxy + Cy^2 = 1,$$ where $$\begin{align*} A &= \frac{\cos^2 \theta}{a^2} + \frac{\sin^2 \theta}{b^2}, \\ B &= \left(\frac{1}{a^2} - \frac{1}{b^2}\right) \sin 2\theta, \\ C &= \frac{\sin^2 \theta}{a^2} + \frac{\cos^2 \theta}{b^2}. \end{align*}$$

Now it should be obvious that the intersection of the red diameter with the ellipse in your second figure is simply the solution to $Ax^2 = 1,$ i.e. $$x = \pm \frac{1}{\sqrt{A}} = \pm \frac{ab}{\sqrt{a^2 \sin^2 \theta + b^2 \cos^2 \theta}}$$ hence the positive value is also half the length of the red diameter.

The blue diameter in the second figure corresponds to the vertical extrema; e.g., what is the largest possible choice of $y$ satisfying $Ax^2 + Bxy + Cy^2 = 1$ for any valid choice of $x$? Some thought should lead you to conclude that this occurs precisely when the quadratic in $x$ $$Ax^2 + (By)x + (Cy^2 - 1) = 0$$ has a repeated root; i.e., the discriminant $$\Delta = (By)^2 - 4A(Cy^2 - 1) = 0.$$ Thus $$y = \pm \frac{2\sqrt{A}}{\sqrt{4AC - B^2}} = \pm \sqrt{a^2 \sin^2 \theta + b^2 \cos^2 \theta}.$$ and the vertical height of the green parallelogram is twice the positive value. The slope of the blue line (after some calculations) should be $$\frac{a^2 \tan \theta + b^2 \cot \theta}{a^2 - b^2},$$ the proof of which is left as an exercise.

I strongly advise you to verify these calculations as I have not spent the time and effort to do so myself.

  • $\begingroup$ Verified working. Accepted. Awesome (-: $\endgroup$ Nov 9, 2017 at 4:56

Let the input parameters be $(a, b, \theta)$, which are respectively the length of major and minor axis and the angle of rotation. Of course the first thing is to rotate the ellipse to the "standard" one $$\frac{x^2}{a^2} + \frac{y^2}{b^2}=4.$$

Let the new ellipse touches the green parallelogram at $(\pm p/2, 0)$ and $\pm (q/2m, q/2)$. Here $p$ is the width (length of the red line), $q$ is the height of the bounding parallelogram and $m$ is the slope of the non-horizontal green line.

Indeed we need only to find a $2\times 2$ matrix $A$ so that $$A\begin{bmatrix} a/2 \\ 0\end{bmatrix} =\begin{bmatrix} p/2 \\ 0\end{bmatrix}, \ \ \ A\begin{bmatrix} 0\\ b/2\end{bmatrix} = \begin{bmatrix} q/2m \\ q/2\end{bmatrix}.$$ Then the rectangle bounding the old ellipse will be sent under $A$ to the green parallelogram, and the standard ellipse will be sent to the new one, as suggested in the comment.

It is easy to see that

$$A = \begin{bmatrix} p/a & q/bm \\ 0 & q/b\end{bmatrix}.$$

Thus the $ 2\times 2$ matrix

$$\begin{bmatrix} p/a & q/bm \\ 0 & q/b\end{bmatrix} \begin{bmatrix} \cos\theta & \sin\theta \\-\sin\theta & \cos\theta\end{bmatrix}$$

will send the ellipse given by $(a, b, \theta)$ to the ellipse given by $(p,q,m)$.

  • $\begingroup$ I wish I knew how to implement this answer to test it. $\endgroup$ Nov 9, 2017 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.