Transforming ellipse arc start and end angles with an arbitrary matrix

107 Views Asked by At

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$?

1

There are 1 best solutions below

7
On BEST ANSWER

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.