1

I have an ellipse arc parametrized with its center ($x_0, y_0$); radii ($a, b$); rotation of the X-axis ($\theta$); and start/end arc angles ($\phi_s, \phi_e$) measured from the ellipse semi-major axis. I also have a 3×3 affine transformation matrix $M$ that includes skew/shear and non-uniform scale.

The problem is to get new parameters for the ellipse after it is transformed with $M$.

I’ve converted the original parameters into matrix representation $Q$, computed $M^{-T}QM^{-1}$, and decomposed it back as explained in What is the equation for an ellipse in standard form after an arbitrary matrix transformation?

Works excellent for the ellipse itself. But I cannot find a proper way to compute transformed start/end arc angles $\phi_s', \phi_e'$. Obviously, they are not kept the same in case of skew transform. I’ve tried to transform “tip” vectors pointing to start/end arc points with $M$ and then get the transformed angles back with dot/cross products against ellipse X-axis, but the best thing I’ve got is a mess shifted by $±\pi/2$ or $±\pi$ multiplied by $±1$ depending on the initial parameter values.

Does anyone have an idea about obtaining $\phi_s', \phi_e'$ from the original $\phi_s, \phi_e$ after transforming with $M$?

HEKTO
  • 1,404
nkrkv
  • 113
  • See: https://math.stackexchange.com/questions/436049/determining-the-angle-degree-of-an-arc-in-ellipse – vvg Oct 03 '22 at 11:16

1 Answers1

1

From the specifications of the problem, the parametric equation of the original ellipse is

$ \mathbf{r}(\phi) = \mathbf{C} + \mathbf{v_1} \cos \phi + \mathbf{v_2} \sin \phi $

where $\mathbf{v_1} = a (\cos \theta, \sin \theta) $ and $\mathbf{v_2} = b (-\sin \theta, \cos \theta) $

Now you apply the affine transformation

$$T(\mathbf{v}) = A \mathbf{v}$$

To the points of the ellipse, then the image points are

$ \mathbf{r'}(\phi) = A \mathbf{C} + A \mathbf{v_1} \cos \phi + A \mathbf{v_2} \sin \phi = \mathbf{C'} + \mathbf{f_1} \cos \phi + \mathbf{f_2} \sin \phi $

Vectors $\mathbf{f_1}$ and $\mathbf{f_2}$ are conjugate radii of the ellipse, and the transformed arc will have the same $\phi_s$ and $\phi_e$ as the original arc.

However, you want the angle relative to the major and minor semi-axes of the transformed ellipse.

For that, we can write

$(\mathbf{r'} - \mathbf{C'} ) = [\mathbf{f_1}, \mathbf{f_2} ] \begin{bmatrix} \cos \phi \\ \sin \phi \end{bmatrix} = F \mathbf{u}(\phi)$

Since $\mathbf{u(\phi)}^T \mathbf{u(\phi)} = 1 $

Then

$(\mathbf{r'} - \mathbf{C'} )^T F^{-T} F^{-1} (\mathbf{r'} - \mathbf{C'}) = 1 $

gives the algebraic equation of the transformed ellipse.

The matrix $Q = F^{-T} F^{-1} $ is positive definite, and symmetric, therefore, it can decomposed into $Q = R D R^T $ where $D$ is diagonal with positive diagonal entries (which are the eigenvalues of $Q$) and $R$ is the matrix of corresponding unit eigenvectors. If we split $D$ into $D = D^{(1/2)}D^{(1/2)} $, then we have

$(\mathbf{r'} - \mathbf{C'} )^T R D^{(1/2)} D^{(1/2)} R^T (\mathbf{r'} - \mathbf{C'}) = 1 $

Now define the new vector $\mathbf{z} = D^{(1/2)} R^T (\mathbf{r'} - \mathbf{C'})$

Then clearly $\mathbf{z}$ is a unit vector, i.e.

$ \mathbf{z} = \begin{bmatrix} \cos \phi' \\ \sin \phi' \end{bmatrix} $

From the above definition, it follows that

$ \mathbf{r'} = \mathbf{C'} + R D^{-(1/2)} \mathbf{z}(\phi') $

Note that the columns of the matrix $R D^{-(1/2)}$ are the two semi-axes of the transformed ellipse, and $\phi'$ is the eccentric angle.

Now recall that,

$ \mathbf{r'} = \mathbf{C'} + F \mathbf{u}(\phi) $

From the equality of the two expressions, it follows that

$ \begin{bmatrix} \cos \phi' \\ \sin \phi' \end{bmatrix} = D^{(1/2)} R^T F \begin{bmatrix} \cos \phi \\ \sin \phi \end{bmatrix} $

Thus given $\phi_s$ and $\phi_e$ we can determine from the above equation, unique values for $\phi'_s$ and $\phi'_e$ (because we have the sine and cosine values for $\phi'$).

As a numerical example, let the original ellipse have $a = 30, b = 18, \theta = \dfrac{\pi}{3}$, and let $\phi_s = \dfrac{\pi}{6}=0.5235987$ and $\phi_e = \dfrac{4 \pi}{3}=4.18879 $, and let the transformation matrix be

$ A = \begin{bmatrix} 2 && - 3 \\ 1 && 5 \end{bmatrix} $

The original elliptical arc in shown in the first figure in black.

enter image description here

The transformed ellipse is drawn in blue in the following figure which was generated using the conjugate radii $\mathbf{f_1}$ and $\mathbf{f_2}$.

enter image description here

Next, to plot the transformed arc using it perpendicular semi-axes, the corresponding transformed angles are computed using the above formula to be

$ \phi'_s = 1.775725 $ and $ \phi'_e = 5.440917 $

Using these values, the transformed ellipse is plotted (in red).

enter image description here

As can be seen, the two arcs are identical.

Hosam Hajeer
  • 21,978
  • Many thanks for the response! I’ll try to implement it in code now. There’s one point in the reasoning that confuses me a little. You write “Vectors $\mathbf{f_1}$ and $\mathbf{f_2}$ are conjugate radii of the ellipse”. I see they are from the algebra above. But, imagine a X-skew transform (the one which transforms a rect into parallelogram). $R_x$ of the ellipse will stay the same and $R_y$ will slant. The angle between them will be no longer $\pi/2$ after transform. So, they are not semi-axes. Thus “and the transformed arc will have the same ϕs and ϕe as the original arc” sounds incorrect :/ – nkrkv Oct 03 '22 at 16:13
  • Please, ignore the previous comment. I’ve confused conjugate radii with semi-axes. – nkrkv Oct 03 '22 at 16:31
  • Have you implemented it in code? Did it work? – Hosam Hajeer Oct 04 '22 at 20:43
  • I’ve tried it in code. Unfortunately it does not produce correct results. The eigen decomp works, the lengths of the arcs (in parameter sense) are beautiful, but the whole thing doesn’t work. In case $A$ contains skew (i.e., when parallel lines are not preserved), $\phi_s', \phi_e'$ get unexpected offset by a few degrees and the arc falls out of a complex curve it was originally part of. I re-read your reasoning ten times and see no mistake. However I still unsure about “…the transformed arc will have the same ϕs and ϕe as the original…” and “…clearly z is a unit vector…” – nkrkv Oct 05 '22 at 17:13
  • Check my updated solution. – Hosam Hajeer Oct 05 '22 at 23:35
  • Oh, thank you! I’ve re-implemented the algorithm step by step from scratch and it works now. Special thanks to pointing where minor/major axis are. You’d make hundreds users of three.js graphics library happier. – nkrkv Oct 11 '22 at 15:25
  • Glad it worked. – Hosam Hajeer Oct 11 '22 at 15:28