1

I am trying to figure out the correct equation or at least an approximate equation for the conditions:

$ \phi_{x,y} < 45\deg $

$ \phi_z = [0, 2*pi] $

For an elliptical curve in 2D (XY plane). However, as indicated by the conditions, I also care about how its rotation around the X and Y axes affect the projected shape of it on the XY plane at z=0 (And assuming all points of the 3D curve are $< 0$ or $> 0$). To clarify, when I refer to $\phi_{xyz}$ I am saying rotations about XYZ axes. I tried a few different approximation methods such as using a 2D rotation applied to the a and b vectors and using this equation found by another user: What is the general equation of the ellipse that is not in the origin and rotated by an angle?

Such that I get:

$ \frac{\left((x-h) \cos \phi_z + (y-k) \sin \phi_z\right)^2}{a'^2} + \frac{\left((x-h) \sin \phi_z - (y-k) \cos \phi_z\right)^2}{b'^2} = 1 $

I solved $a'^2$ and $b'^2$ by:

$ A_0 = \begin{pmatrix} a_x \\ a_y \end{pmatrix}, \quad B_0 = \begin{pmatrix} b_x \\ b_y \end{pmatrix} $

Where:

$ a_x = a \cos \phi_z, \quad a_y = a \sin \phi_z $

Matrix $R$ and the transformed matrix $A_1$:

$ R = \begin{pmatrix} \cos \phi_z & -\sin \phi_z \\ \sin \phi_z & \cos \phi_z \end{pmatrix} $

$ A_1 = R A_0 = \begin{pmatrix} a_x \cos \phi_z - a_y \sin \phi_z \\ a_x \sin \phi_z + a_y \cos \phi_z \end{pmatrix} $

$ a' = \sqrt{A_{z,x}^2 + A_{z,y}^2} $

$ a'^2 = a^2 (cos^2\phi_z cos^2 \phi_y + sin^2\phi_z cos^2 \phi_x) $

Similar operations for $B_1$ lead to $b'^2$. But when I plot it and modify the angles, it alters the size of the ellipse for both of the x and y components of a and b. So I tried a dumber way that I knew was wrong but hoping given the conditions, it may work under those at least:

$ A(x'-h)^2 + B(x'-h)(y'-k) + C(y'-k)^2 = 1 $

$ A = \frac{\cos^2 \phi}{a^2} + \frac{\sin^2 \phi}{b^2}, $ $ B = 2 \cos \phi \sin \phi \left( \frac{1}{a^2} - \frac{1}{b^2} \right), $ $ C = \frac{\sin^2 \phi}{a^2} + \frac{\cos^2 \phi}{b^2} $

$ x' = xcos\phi_y, \quad y' = ycos\phi_x $

Also didn't work. Even when I went as far as to use the actual 3D rotation matrix $R$ and it still did not give a correct solution. The other problem with it is that the order of rotation shouldn't matter physically (Since I am trying to model something physical with this and only care about final orientation) but that does matter in the math. I am not trying to model a time dependent process and only care about the final orientation of this parametric curve in R3, projected into R2, so I don't even think that using the formal Rotation matrix RzRyRx is even appropriate here since the order matters where in reality it shouldn't. Any other recommendations others have or maybe can point out what I did incorrectly in some of the different methods I tried and showed here that can give an accurate solution? Is there even an analytical solution or do I need to resort to numerical computation? Ideally I'd like to have a solution that works for the conditions:

$ \phi_{x,y} <= 180\deg $

$ \phi_z = [0, 2*pi] $

But if it gets too complicated, then the initial condition pair I mentioned is okay too.

Sophia
  • 23
  • 4

1 Answers1

3

The elliptical curve (or ellipse) can be specified in $3D$ space most preferably using a vector parametric equation as follows

$ r(t) = C + v_1 \cos t + v_2 \sin t $

were $C, v_1 , v_2 \in \mathbb{R}^3$, $C$ is the center and $v_1$ and $v_2$ are conjugate radii of the ellipse (which can also be the semi-major axis and semi-minor axis, if they are orthogonal to each other).

The projection of the ellipse onto the $XY$ plane is produced using the projection matrix $P$ , which is

$ P = I - \mathbf{k k}^T = \begin{bmatrix} 1 && 0 && 0 \\ 0 && 1 && 0 \\ 0 && 0 && 0 \end{bmatrix} $

So the projected ellipse is

$ p(t) = P r(t) = P C + P v_1 \cos t + P v_2 \sin t $

Define $ G = PC , u_1 = P v_1 , u_2 = P v_2 $ as two-dimensional vectors by ignoring the $z$ component which is identically zero, then

$ p(t) = G + u_1 \cos t + u_2 \sin t $

Therefore,

$ (p(t) - G) = U \begin{bmatrix} \cos t \\ \sin t \end{bmatrix} $

where $U = [u_1, u_2] $ is $ 2 \times 2$ matrix.

Hence,

$ w = \begin{bmatrix} \cos t \\ \sin t \end{bmatrix} = U^{-1} ( p - G ) $

Since $w^T w = \cos^2 t + \sin^2 t= 1 $ , then

$ (p - G)^T U^{-T} U^{-1} (p - G) = 1 $

And this is the exact equation of the projected ellipse.


If you want to find the rotation of the original ellipse with respect to the $XYZ$ axes, then you need to find the major and minor axes of the ellipse, then use this information to relate these axes to the axes in the standard position, where the major axis is along the $X$ axis and the minor axis is along the $Y$ axis.


To extract the major and minor semi-axes from the conjugate semi-axes $ v_1 $ and $v_2$ (assuming $v_1$ is not perpendicular to $v_2$), then from

$ r(t) = C + v_1 \cos t + v_2 \sin t $

The relative displacement of $r(t)$ from the center $C$ is

$ v(t) = r(t) - C = v_1 \cos t + v_2 \sin t $

The magnitude of $v(t)$ is maximum when $v(t)$ is pointing along a major semi-axis, and is minimum when $v(t)$ is pointing along a minor semi-axis. So all we have to do find a semi-major and a semi-minor axis is find the magnitude of $v(t)$ and find the values of $t$ at which is maximum and minimum.

The magnitude squared of $v(t)$ is

$ v^T(t) v(t) = (v_1 \cos t + v_2 \sin t )^T (v_1 \cos t + v_2 \sin t ) = v_1^T v_1 \cos^2 t + v_2^T v_2 \sin^2 t + 2 v_1^T v_2 \cos t \sin t $

And this simplifies to

$ v^T(t) v(t) = \dfrac{1}{2} (v_1^T v_1 + v_2^T v_2) + \dfrac{1}{2} (v_1^T v_1 - v_2^T v_2 ) \cos(2 t) + v_1^T v_2 \sin(2 t) $

The maximum of this trigonometric function of $(2t)$ is obtained when the vector $(\cos(2 t) , \sin(2 t)) $ is along the vector $( \dfrac{1}{2} (v_1^T v_1 - v_2^T v_2) , v_1^T v_2 ) $, i.e. when

$ t = t_{Major} = \dfrac{1}{2} \tan^{-1} \left( \dfrac{ 2 v_1^T v_2 }{ v_1^T v_1 - v_2^T v_2 } \right) $

And similarly, the function $v^T(t) v(t)$ is minimum when the vector $(\cos(2t), \sin(2t)) $ is opposite in direction to the vector $(\dfrac{1}{2} (v_1^T v_1 - v_2^T v_2) , v_1^T v_2 ) $, i.e. when

$ t = t_{Minor} = \dfrac{\pi}{2} + t_{Major} $

With these two values of $t$ we substitute into $v(t)$ to get the semi-major and semi-minor axes of the original ellipse.


Next, we'll set up a reference coordinate frame with its origin at $C$, and whose $X$ axis (let's call it X' axis) is along the semi-major axis of the ellipse, and whose $Y'$ axis is along the semi-minor axis. Forming the cross product between these two directions gives the $Z'$ axis. These three unit directions define a rotation matrix $R$ as follows

$ R = [ \hat{x'}, \hat{y'}, \hat{z'} ] $

That is, the columns of $R$ are the unit directions along the $X'$ , $Y'$ and $Z'$ directions.

The matrix defines the $3D$ rotation that occurred to the congruent ellipse which is in standard position (and this means the ellipse that has its semi-major axis along the $X$ axis, and semi-minor axis along the $Y$ axis).


If you want to go one step further, to find the consecutive rotations about the $X$ , $Y$, $Z$ axes that result in the overall rotation matrix $R$, then to find the angles of rotation about $X, Y, Z$, assuming we rotated about $X$ first then about $Y$, and finally about $Z$, where all rotations are made about the fixed axes $X, Y, Z$, then we express the $R$ we found as follows

$ R = R_z(\theta_3) R_y(\theta_2) R_x(\theta_1) $

It is well known that

$ R_x(\theta_1) = \begin{bmatrix} 1 && 0 && 0 \\ 0 && \cos(\theta_1) && - \sin(\theta_1) \\ 0 && \sin(\theta_1) && \cos(\theta_1) \end{bmatrix} $

And that

$ R_y (\theta_2) = \begin{bmatrix} \cos(\theta_2) && 0 && \sin(\theta_2) \\ 0 && 1 && 0 \\ - \sin(\theta_2) && 0 && \cos(\theta_2) \end{bmatrix} $

And

$ R_z (\theta_3) =\begin{bmatrix} \cos(\theta_3) && - \sin(\theta_3) && 0 \\ \sin(\theta_3) && \cos(\theta_3) && 0 \\ 0 && 0 && 1 \end{bmatrix} $

It can be shown without much difficulty that

$ R_z(\theta_3) R_y(\theta_2) R_x(\theta_1) = \begin{bmatrix} c_3 c_2 && c_3 s_1 s_2 - s_3 c_1 && c_3 c_1 c_2 + s_3 s_1 \\ s_3 c_2 && s_3 s_1 s_2 + c_3 c_1 && s_3 c_1 s_2 - c_3 s_1 \\ -s_2 && s_1 c_2 && c_1 c_2 \end{bmatrix} $

where $c_1 = \cos(\theta_1), s_1 = \sin(\theta_1), c_2 = \cos(\theta_2), s_2 = \sin(\theta_2),c_3 = \cos(\theta_3), s_1 = \sin(\theta_3)$

Therefore, the angle of rotation about the $Y$ axis (which is the second rotation) is given by

$ \theta_2 = \sin^{-1} (-R_{31} ) $

And the 3rd row gives us,

$ \theta_1 = \text{atan2}( R_{33}, R_{32} ) $

And the first column gives,

$ \theta_3 = \text{atan2}( R_{11}, R_{21} ) $

Where the $\text{atan2}(x,y)$ returns the angle of the point $(x,y)$ in the cartesian plane. That is, it returns the angle $\phi$ such that $\cos \phi = \dfrac{x}{\sqrt{x^2 + y^2}} $ and $\sin \phi = \dfrac{y}{\sqrt{x^2 + y^2}} $.


  • Hi, thanks for the response! But I also need to know what the rotation is of this ellipse as well wrt each axis. Therefore, wouldn't I still need to apply the 3D rotation transformation onto it to get the correct output. For example: r_rotated(t) = R(thetaZ)R(thetaY)R(thetaX)*r(t) which means I am back to my original issue of why these rotation orders even matter if physically they do not? – Sophia Sep 30 '24 at 05:46
  • No. The projected ellipse is an ellipse but it is not obtained from the original ellipse by rotation. The projected ellipse has a different semi-major and semi-minor axis. Remember that rotating an object preserves its dimensions, which is not the case here. –  Sep 30 '24 at 06:39
  • I understand that, but what I mean is that the original, 3D ellipse has a measurable orientation wrt an imposed, external coordinate system. So would that mean that the vectors v_1 and v_2 would contain that information about its 3D orientation and if so, that is where I am stuck as well knowing. The measured values that would go into defining the equation are thetaXYZ and the major/minor diameters of the ellipse. I know that you said that v_1 and v_2 contain that semi major/minor information, so how would the orientations also be included (thetaXYZ)? – Sophia Sep 30 '24 at 07:57
  • This is all before the projection to 2D is even done. So it's about how to define the r(t) equation initially with those explicitly contained inputs. You defined it generally, but I can't see how thetaXYZ is implemented within it. – Sophia Sep 30 '24 at 07:59
  • @Sophia Please check my updated solution. I've added details concerning the rotation of the original ellipse. –  Sep 30 '24 at 10:58
  • Thank you for the complete response. So it does seem that I will need to use the R rotation 3D matrix and apply it to the r(t) equation to get the corrected v1 and v2 vectors. I do have the thetaXYZ and major/minor axes measurements available to me, so I just need to plug them into the rotation matrix and r(t) equation to get the r_rotated(t) function then. – Sophia Sep 30 '24 at 16:37
  • Correct. You got it. –  Sep 30 '24 at 16:42