# Parameters of the conic curve resulting from the perspective projection of a circle

I'm trying to compute the angle and major/minor axes of the perspective projection of a circle. The circle is embedded in $\mathbb R^3$ space with any orientation not perpendicular to the screen, but I use the plane $z=1$ for screen and $(0,0,0)$ as my focal point.

I manage to get the equation of the conic in general form, but in the case it is an ellipse, the computation to get the center axis-aligned form gets out of hand and I'm feeling I'm missing something to compute it.

So here is what I've done. Let be a circle of center $c = (c_x, c_y, c_z)$ and radius $r$, with a normal $\mathbf n = (n_x,n_y,n_z)$. It is described by the following set of equations, one equation of a plane and one of a sphere, \begin{gather} \begin{cases} (x-c_x)^2 + (y-c_y)^2 + (z-c_z)^2 = r^2, \\ n_x (x - c_x) + n_y (x - c_y) + n_z (x - c_z) = 0.\\ \end{cases} \end{gather}

They reduce to


where $\langle\_|\_\rangle$ is the scalar product.

My perspective projection is the function

\begin{align*} f: & \mathbb R^3 \to \mathbb R^2 \times \{1\} \\ & (x,y,z) \mapsto \left( \frac xz, \frac yz \right)\\ \end{align*}

And the inverse projection to the plane containing the circle is \begin{align*} f^{-1}: \mathbb R^2 \times \{1\} \to& \mathbb{R}^3 \\ (x,y,1) \mapsto& \left( \frac{x\nc}{\nxy}, \frac{y\nc}{\nxy}, \frac{\nc}{\nxy} \right)\\ \end{align*}

If $(x,y)$ is part of the projected circle, then the inverse projection of that point must also be on the sphere that contained the circle.

\begin{gather*} (f^{-1}(x)-c_x)^2 + (f^{-1}(y)-c_y)^2 + (f^{-1}(z)-c_z)^2 = r^2 \\ \end{gather*}

Expanding that, we have \begin{gather*} f^{-1}(x)^2 - 2c_xf^{-1}(x) + c_x^2 + f^{-1}(y)^2 - 2c_yf^{-1}(y) + c_y^2 + f^{-1}(z)^2 - 2c_zf^{-1}(z) + c_z^2 - r^2 = 0 \\ \end{gather*} \begin{align} \left(\frac{x\nc}{\nxy}\right)^2 - 2c_x\frac{x\nc}{\nxy} + c_x^2 + \left(\frac{y\nc}{\nxy}\right)^2 - 2c_y\frac{y\nc}{\nxy} + c_y^2 &\\ + \left(\frac{\nc}{\nxy}\right)^2 - 2c_z\frac{\nc}{\nxy} + c_z^2 - r^2 &= 0 \\ \end{align}

Still expanding, this already gets quite verbose

\begin{align*} &\left(x\nc\right)^2 &&- 2c_x x\nc \nxy &&+ c_x^2 \nxy^2 \\ +& \left(y\nc\right)^2 &&- 2c_y y\nc \nxy &&+ c_y^2 \nxy^2 \\ +& \left(\nc\right)^2 &&- 2c_z \nc \nxy &&+ c_z^2 \nxy^2 -r^2 \nxy^2 = 0 \end{align*}

\begin{align*} & \nc^2 x^2 &-& 2 c_x \nc n_x x^2 &-& 2 c_x \nc n_y xy &-& 2 c_x \nc n_z x &\\ +& c_x^2 n_x^2 x^2 &+& c_x^2 n_y^2 y^2 &+& c_x^2 n_z^2 &+& 2 c_x^2 n_x n_y xy &+& 2 c_x^2 n_x n_z x &+& 2 c_x^2 n_y n_z y &\\ +& \nc^2 y^2 &-& 2 c_y \nc n_x xy &-& 2 c_y \nc n_y y^2 &-& 2 c_y \nc n_z y &\\ +& c_y^2 n_x^2 x^2 &+& c_y^2 n_y^2 y^2 &+& c_y^2 n_z^2 &+& 2 c_y^2 n_x n_y xy &+& 2 c_y^2 n_x n_z x &+& 2 c_y^2 n_y n_z y &\\ +& \nc^2 &-& 2 c_z \nc n_x x &-& 2 c_z \nc n_y y &-& 2 c_z \nc n_z &\\ +& c_z^2 n_x^2 x^2 &+& c_z^2 n_y^2 y^2 &+& c_z^2 n_z^2 &+& 2 c_z^2 n_x n_y xy &+& 2 c_z^2 n_x n_z x &+& 2 c_z^2 n_y n_z y &\\ -& r^2 n_x^2 x^2 &-& r^2 n_y^2 y^2 &-& r^2 n_z^2 &-& 2 r^2 n_x n_y xy &-& 2 r^2 n_x n_z x &-& 2 r^2 n_y n_z y &=& \quad 0 \\ \end{align*}

Now, writing the quadratic equation by component in the form $A\,xy + B\, x^2 + C\,y^2 + D\,x + E\,y + F$, the factors are as below.

\begin{align*} x y &:A=&& &-& &2& (c_xn_y + c_yn_x) \nc &+& &2& \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y \\ x^2 &:B=&& \nc^2 &-& &2& c_x n_x \nc &+& & & \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_x^2 \\ y^2 &:C=&& \nc^2 &-& &2& c_y n_y \nc &+& & & \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_y^2 \\ x &:D=&& &-& &2& (c_x n_z + c_z n_x) \nc &+& &2& \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_x n_z \\ y &:E=&& &-& &2& (c_y n_z + c_z n_y) \nc &+& &2& \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_y n_z \\ 1 &:F=&& \nc^2 &-& &2& c_z n_z \nc &+& & & \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_z^2 \\ \end{align*}

According to wikipedia, this quadratic equation is an ellipse if $4BC - A^2 > 0$.

I'll spare you the details, but I check that condition and arrived at the conclusion that

\begin{gather*} r < \frac{ \sqrt{n_x^2 + n_y^2 + n_z^2} }{\sqrt{n_x^2 + n_y^2} } |c_z| \end{gather*}

must be true. It seems reasonable as it means that the circle must not cross the plane $z=0$.

However, now I want to compute the anngle of the projected ellipse relative to the x-axis. Again, according to wikipedia, this can be computed with the following formula : \begin{gather*} \theta = \begin{cases} 0 \text{ if } A = 0, B < C \\ \frac\pi2 \text{ if } A = 0, B > C \\ \arctan\frac{C - B - \sqrt{(C-B)^2 + A^2}}{A} \text{ if } A \ne 0 \end{cases} \end{gather*}

Let's assume for now that $A \ne 0$, and let's compute $\frac{C - B - \sqrt{(C-B)^2 + A^2}}{A}$.

This is where this is getting ugly. So, first I replace the $A$, $B$ and $C$ values. \begin{gather*} \frac{ \left( \nc^2 - 2 c_y n_y \nc + \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_y^2 \right) - \left( \nc^2 - 2 c_x n_x \nc + \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_x^2 \right) } { - 2 (c_xn_y + c_yn_x) \nc + 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y }\\ +\frac{ -\sqrt{ \begin{gathered} \left( \left( \nc^2 - 2 c_y n_y \nc + \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_y^2 \right) - \left( \nc^2 - 2 c_x n_x \nc + \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) n_x^2 \right) \right)^2\\ + \left( - 2 (c_xn_y + c_yn_x) \nc + 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y \right) ^2 \end{gathered} } } { - 2 (c_xn_y + c_yn_x) \nc + 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y } \end{gather*}

The two first lines are one giant numerator as are the three lines that are part of the square root. Now let's compute more (I wont't write the equality symbols).

\begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) \nc } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc }\\ +\frac{ -\sqrt{ \begin{gathered} \Big( \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) \nc \Big)^2\\ + \Big( 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc \Big) ^2 \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc } \end{gather*}

Then, \begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) \nc } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc }\\ +\frac{ -\sqrt{ \begin{gathered} \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 (n_x^2 - n_y^2)^2 + 4 \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) ( c_x n_x - c_y n_y ) \nc\\ + 4 ( c_x n_x - c_y n_y )^2 \nc^2 \\ + 4 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right)^2 n_x^2 n_y^2 - 8 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y (c_xn_y + c_yn_x) \nc \\ + 4 (c_xn_y + c_yn_x)^2 \nc^2 \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc } \end{gather*}

Then, \begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) \nc } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc }\\ +\frac{ -\sqrt{ \begin{gathered} \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^4 -2 \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^2 n_y^2 +\left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_y^4 \\ + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x^3 + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_x^2 n_y \\ + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x n_y^2 + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_y^3 \\ + 4 \nc^2 c_x^2 n_x^2 + 8 \nc^2 c_x c_y n_x n_y + 4 \nc^2 c_y^2 n_y^2 \\ + 4 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right)^2 n_x^2 n_y^2 \\ - 8 \nc \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) c_x n_x n_y^2 - 8 \nc \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) c_y n_x^2 n_y \\ + 4 \nc^2 c_x^2 n_y^2 + 8 \nc^2 c_x c_y n_x n_y + 4 \nc^2 c_y^2 n_x^2 \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc } \end{gather*}

Then, \begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) \nc } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc }\\ +\frac{ -\sqrt{ \begin{gathered} \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^4 +2 \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^2 n_y^2 +\left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_y^4 \\ + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x^3 - 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_x^2 n_y \\ - 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x n_y^2 + 4 \nc \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_y^3 \\ + 4 \nc^2 c_x^2 n_x^2 + 4 \nc^2 c_x^2 n_y^2 + 4 \nc^2 c_y^2 n_x^2 + 4 \nc^2 c_y^2 n_y^2 + 16\nc^2 c_x c_y n_x n_y \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) \nc } \end{gather*}

Then, \begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) (n_xc_x+n_yc_y+n_zc_z) } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) (n_xc_x+n_yc_y+n_zc_z) }\\ +\frac{ -\sqrt{ \begin{gathered} \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^4 +2 \left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_x^2 n_y^2 +\left(c_x^2 + c_y^2 + c_z^2 - r^2\right)^2 n_y^4 \\ + 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x^3 - 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_x^2 n_y \\ - 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x n_y^2 + 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_y^3 \\ + 4 (n_xc_x+n_yc_y+n_zc_z)^2 c_x^2 n_x^2 + 4 (n_xc_x+n_yc_y+n_zc_z)^2 c_x^2 n_y^2 + 4 (n_xc_x+n_yc_y+n_zc_z)^2 c_y^2 n_x^2 \\ + 4 (n_xc_x+n_yc_y+n_zc_z)^2 c_y^2 n_y^2 + 16(n_xc_x+n_yc_y+n_zc_z)^2 c_x c_y n_x n_y \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) (n_xc_x+n_yc_y+n_zc_z) } \end{gather*}

And finally I reach this monster : \begin{gather*} \frac{ \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) (n_x^2 - n_y^2) + 2 ( c_x n_x - c_y n_y ) (n_xc_x+n_yc_y+n_zc_z) } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) (n_xc_x+n_yc_y+n_zc_z) }\\ +\frac{ -\sqrt{ \begin{gathered} c_x^4 n_x^4 + c_y^4 n_x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left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x^3 \\ - 4 c_x^3 c_y n_x^3 n_y - 4 c_x c_y^3 n_x^3 n_y - 4 c_x c_y c_z^2 n_x^3 n_y + 4 c_x c_y r^2 n_x^3 n_y - 4 c_x^2 c_y^2 n_x^2 n_y^2 - 4 c_y^4 n_x^2 n_y^2 - 4 c_y^2 c_z^2 n_x^2 n_y^2 \hfill\\\hfill + 4 c_y^2 r^2 n_x^2 n_y^2 - 4 c_x^2 c_y c_z n_x^2 n_y n_z - 4 c_y^3 c_z n_x^2 n_y n_z - 4 c_y c_z^3 n_x^2 n_y n_z + 4 c_y c_z r^2 n_x^2 n_y n_z %- 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_y n_x^2 n_y \\ - 4 c_x^4 n_x^2 n_y^2 - 4 c_x^2 c_y^2 n_x^2 n_y^2 - 4 c_x^2 c_z^2 n_x^2 n_y^2 + 4 c_x^2 r^2 n_x^2 n_y^2 - 4 c_x^3 c_y n_x n_y^3 - 4 c_x c_y^3 n_x n_y^3 - 4 c_x c_y c_z^2 n_x n_y^3 \hfill\\\hfill + 4 c_x c_y r^2 n_x n_y^3 - 4 c_x^3 c_z n_x n_y^2 n_z - 4 c_x c_y^2 c_z n_x n_y^2 n_z - 4 c_x c_z^3 n_x n_y^2 n_z + 4 c_x c_z r^2 n_x n_y^2 n_z %- 4 (n_xc_x+n_yc_y+n_zc_z) \left(c_x^2 + c_y^2 + c_z^2 - r^2\right) c_x n_x n_y^2 \\ + 4 c_x^3 c_y n_x n_y^3 + 4 c_x c_y^3 n_x n_y^3 + 4 c_x c_y c_z^2 n_x n_y^3 - 4 c_x c_y r^2 n_x n_y^3 + 4 c_x^2 c_y^2 n_y^4 + 4 c_y^4 n_y^4 + 4 c_y^2 c_z^2 n_y^4 \hfill\\\hfill - 4 c_y^2 r^2 n_y^4 + 4 c_x^2 c_y c_z n_y^3 n_z + 4 c_y^3 c_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2 c_z n_x n_y^2 n_z %+ 16(n_xc_x+n_yc_y+n_zc_z)^2 c_x c_y n_x n_y \end{gathered} } } { 2 \left(c_x^2 + c_y^2 + c_z ^2 - r^2\right) n_x n_y - 2 (c_xn_y + c_yn_x) (n_xc_x+n_yc_y+n_zc_z) } \end{gather*}

At which point I give up because I don't know an efficient way to simplify that. So, my question is, do you know an alternate strategy to compute that angle $\theta$ ? Or do you know a way to simplify that ugly square root or a proper way to approximate it ?

Thank you for any help (and sorry if Mathjax is a bit bloated).

Originally I had suggested that starting from the general form you found, you can extract center, orientation and radii of the ellipse following e.g. the steps I wrote in this answer. But I guess that approach misses the point of finding a closed formula for the angle. The comment by Jan-Magnus Økland already suggests an approach for that, namely going from $\tan\theta$ to $\tan2\theta$. To this effect read Wikipedia to find

$$\tan2\theta=\frac{2\tan\theta}{1-\tan^2\theta}$$

Where does the $\theta=\arctan\frac{C - B - \sqrt{(C-B)^2 + A^2}}{A}$ come from? This looks like the solution to some quadratic equation, using the well-known quadratic formula. A bit of experimenting and you find a corresponding quadratic equation

\begin{align*} \frac12A\tan^2\theta+(B-C)\tan\theta-\frac12A&=0\\ 2\tan\theta(B-C)&=\left(1-\tan^2\theta\right)A\\ \tan2\theta=\frac{2\tan\theta}{1-\tan^2\theta}&=\frac{A}{B-C}\\ \theta&=\frac12\arctan\frac{A}{B-C}+k\frac\pi2 \end{align*}

for some $k\in\mathbb Z$ which gives the angle up to some multiple of $\frac\pi2$ as is to be expected. Picking the right one among these algebraically equivalent ones is hard to do with a closed formula.

But I'd also suggest you revisit how you obtain that general form in the first place. Here is a higher level view which avoids much of the tedious coordinate computation.

A point $p$ is on your circle if $\langle p-c|p-c\rangle=r^2$ and $\langle p-c|n\rangle=0$. You already have that much, although not using this notation. Rewrite these conditions to

\begin{align*} \langle p|p\rangle-2\langle p|c\rangle+\langle c|c\rangle-r^2&=0\\ \langle p|n\rangle -\langle c|n\rangle&=0 \end{align*}

The first equation now has a quadratic term, a linear term and a constant term. The second equation has only a linear and a constant term. If your final projected point on the plane is $q=(x,y,1)$, then the corresponding preimage is some multiple thereof, i.e. some $p=tq$ for $t\in\mathbb R$. You can plug this into the equation of the plane and solve for $t$:

\begin{align*} \langle tq|n\rangle-\langle c|n\rangle&=0\\ t\langle q|n\rangle&=\langle c|n\rangle\\ t&=\frac{\langle c|n\rangle}{\langle q|n\rangle} \end{align*}

Then use this in the equation of the sphere:

\begin{align*} t^2\langle q|q\rangle-2t\langle q|c\rangle+\langle c|c\rangle-r^2&=0\\ \langle c|n\rangle^2\langle q|q\rangle -2\langle c|n\rangle\langle q|n\rangle\langle q|c\rangle +\langle q|n\rangle^2\left(\langle c|c\rangle-r^2\right)&=0 \end{align*}

Note how I avoided division by multiplying the whole equation by the square of the denominator of $t$. If you are deep into bra-ket notation, you could also write all of this as

$$\langle q|\,\left( \langle c|n\rangle^2\cdot\mathbf 1 -\langle c|n\rangle\cdot|c\rangle\langle n| -\langle n|c\rangle\cdot|n\rangle\langle c| +\left(\langle c|c\rangle-r^2\right)\cdot|n\rangle\langle n| \right)\,|q\rangle=0$$

where $|\_\rangle\langle\_|$ denotes the outer product of two vectors, i.e. a $3\times3$ matrix. So the big parenthesis contains a sum of four terms. Each of these terms is scalar times matrix. The first matrix is the identity matrix $\mathbf 1$ which is symmetric. The second and third term are mutually transpose, so their sum is symmetric. (Writing $\langle c|n\rangle$ as the scalar factor for one term and $\langle n|c\rangle$ for the other is merely to highlight the symmetry, they are of course the same number.) The last matrix uses twice the same vector so it is symmetric, too. Thus the whole big parenthesis describes a symmetric matrix. Using a bit of a more conventional notation and assuming column vectors, you could write this as

$$q^T\,\left( (c^Tn)^2\,\mathbf 1 -(c^Tn)(cn^T) -(n^Tc)(nc^T) +(c^Tc-r^2)(nn^T) \right)\,q=0$$

The matrix computed by the big parenthesis is the homogeneous matrix representation of your conic section. When you wrote “I manage to get the equation of the conic in general form”, this is what I had expected at first. In the notation you use, this matrix corresponds to

$$\begin{pmatrix}B&A/2&D/2\\A/2&C&E/2\\D/2&E/2&F\end{pmatrix}$$

I do hope that the above will give you some idea of how to obtain these parameters in a more high-level view, with less coordinates cluttering the path. The $3\times3$ matrix notation can be useful for other parameters as well. For example the center of the conic has homogeneous coordinates equal to the cross product of the first two columns of that matrix.

• It’d be interesting to tease some geometric meaning out of that matrix. E.g., the first two terms can be extended to $\mathbb{RP}^3$ as a parallel projection onto a plane through the origin with normal $n$ in the direction of $c$. – amd Aug 31 '17 at 23:06
• However I wanted to properly "visualize" the projected ellipse, hence the wish get the angle $\theta$ . Maybe the 3×3 matrix is more practical for computations, but it doesn't really tell what $\theta$ is… Thank you for the straight answer to compute $\theta$ though. – Lærne Sep 4 '17 at 9:39

I don't know if this answer will be of help to you, nonetheless I would like to show a more geometric approach.

In diagram below, $A=(0,0,0)$ is the projection point, the yellow plane is the screen ($z=1$) while the circle (of center $G$) lies on the blue plane. The two planes meet at a certain line $r$ (dashed red) and let $BC$ be that diameter of the circle such that line $BC$ is perpendicular to $r$. Moreover, let $F$ be the intersection of line $BC$ with plane $z=0$.

If projection lines $AB$ and $AC$ meet the screen at $M$ and $N$, $MN$ is a diameter of the projected ellipse and its midpoint $O$ is thus the center of the ellipse. Its conjugate diameter $ED$ lies on the line through $O$ parallel to $r$, and $$OD=OE=OM{\sqrt{BF\cdot CF}\over AF}.$$

Once you have two conjugate diameters, you can find the principal axes as follows (see diagram below). In the plane of the ellipse, draw line $QQ'$ through $N$ perpendicular to $DE$. Points $Q$ and $Q'$ must be chosen such that $NQ=NQ'=OD$. Principal axes $IR$ and $ST$ lie then on the bisectors of the angles formed by lines $OQ$ and $OQ'$, and: $$IR=OQ'+OQ,\quad TS=OQ'-OQ.$$

• A beautiful and simple geometric solution. Much nicer than the intersection of cone and plane that I’d been considering. – amd Aug 31 '17 at 22:54
• @amd The first construction is based on Apollonius' Conica, Prop. I-13, the second one on Problem 62 in "Constructive Geometry" by Eagles. – Aretino Sep 1 '17 at 7:20
• Actually this answer helps me the most, as I wanted to be able to visualize and construct projected circles with a ruler and a compass. I attempted to compute the the angle algebraically first as I'm a bit more comfortable with that. But very nicely done. – Lærne Sep 4 '17 at 9:42
• Geometric intuition says that as $r$ approaches the upper limit given in the question (that is, the circle becomes nearly tangent to the $x,y$ plane), the major axis of the ellipse will be nearly parallel to the line through the origin and the point where the circle would be tangent to the $x,y$ plane. It would be useful to have a corresponding intuition about the limiting direction of the major axis as $r$ approaches zero. – David K Sep 4 '17 at 14:17
• @DavidK Hmm... if $r$ is small relative to the distance of the circle’s center from the origin, then the projection is close to parallel, so there’s a combination of foreshortening perpendicular to the intersection of the circle’s plane and a plane normal to $c$, and foreshortening perpendicular to the intersection of the latter plane with $z=1$. This makes me think that as $r\to0$ the major axis approaches some line between this second intersection and the projection of the first intersection, but I haven’t thought about it enough to come up with a sharper estimate. – amd Sep 5 '17 at 1:50


It seems to me that this is a simplified formula for the angle you are trying to compute. (By "this" I mean everything after the word found and before the word it in the text above. I have nearly copied this directly from the question, except that I have used the bra-ket notation to express $c_x^2+c_y^2+c_z^2$ a little more succinctly and I have rearranged some terms.) Considering the number of inputs into the problem ($r$ and all the components of $c$ and $\n$), the formula is not even especially complicated. It only becomes unwieldy when you expand it.

Moreover, I would argue that this is a closed-form expression in the strictest sense, because it gives you a bounded number of steps in which to compute the value, every step consisting of an operation such as addition, subtraction, multiplication, division, the square root, and the arc tangent function (and we could get rid of the arc tangent if you are willing to accept coefficients of an equation of the major axis instead of requiring an angle in radians).

If you are willing to consider a separate formula for the $A\neq 0$ case, you can write $$\tan\theta = \frac{H - \sqrt{H^2 + A^2}}{A}$$ where \begin{align} A &= 2 n_x n_y \left(\braket cc - r^2\right) - 2 (c_x n_y + c_y n_x) \braket\n c, \\ H &= \left(n_y^2 - n_x^2\right)\left(\braket cc - r^2\right) - 2 (c_y n_y - c_x n_x) \braket\n c. \end{align}

If you don't like the use of the word where and the way I go in and out of "display" mode within the blocks of text that I am calling closed-form expressions, you can adopt a more formal notation that will allow you to have the effect of the word where within one continuous symbolic expression. An example of such a notation is the LET construct in Leslie Lamport's TLA+ specification language.

These formulas are simple enough to start plugging in numbers to explore the behavior of the conic. For example, let's take $\n = (0.6,0,0.8)$ and $c = (0,3,4).$ Since $n_y = 0,$ these conditions give us $A = -11.52$ independent of $r.$ But $\left(n_y^2 - n_x^2\right) = -0.36,$ so $H$ varies as $r$ varies. A little calculation (I find a software spreadsheet is useful for this) shows that $\tan\theta \approx 1.13278$ when $r = 1$ but $\tan\theta \approx 0.71368$ when $r = 4.$ That is, the angle $\theta$ does depend on $r.$

$\endgroup$

• I wanted a formula simple enough I could get a sense of $\theta$ by knowing $r$, $c$ and $\mathbb n$. I had an intuition that $r$ could be eliminated as I can't picture it being a factor that affects $\theta$ (but maybe I'm wrong). – Lærne Sep 4 '17 at 9:47
• Knowing that you were hoping to eliminate $r$ turns out to be important information for answering your question--especially since it turns out that $\theta$ depends on $r$ after all, so we cannot eliminate $r.$ (See the paragraph that I have added to the end of the answer.) One doesn't usually think of cataloging all the things that cannot be eliminated from a formula. – David K Sep 4 '17 at 13:56
• On a second thought, I explicitly computed the discriminant that tells whether it's an ellipse, parabola or hyperbola and it was dependent on $r$, so there was virtually no chance the other parameters wouldn't be. – Lærne Sep 5 '17 at 8:55