[Math] Rotation of an ellipse using a rotation matrix

geometry

I'm struggling on this problem without finding any solution:

I have 2 points $p0=[x_0, z_0]$ and $p1=[x_1, z_1]$ in a plane (x, z).
I want to calculate the Fresnel zone and the Line of Sight between the two points.

The fresnel zone can be easily calculated using this formula,where $\lambda$ is the wavelenght and $d$ is the distance between the two points:

$$z(x) = \sqrt{\frac{\lambda*x*(d-x)}{d}}$$

The line of sight between two points is a simple constant:
$$z(x) = z_1$$

The problem pops out when I the two points are on different heigts. In that case I need to rotate the ellipse by an angle $\theta = tan^{-1}(m)$

Using a rotation matrix I calculated the formula for the rotated ellipse:
$$z(x) = \sqrt{\frac{\lambda*x*(d-x)}{d}}*cos(\theta) + x*sin(\theta)$$

The LOS formula is a simple linear equation:
$$z(x) = m*x + z_0$$

What I expect to have is an ellipse simmetric to the LOS line.
Instead what I get is this weird conic: plotted conic

Could you please help me finding out where is my mistake?
I also tryied to use python shapely building the ellipse on the origin and then rotating it, but i have the very same problem.

Thanks, Gabriele

Best Answer

Your basic problem is that you didn’t rotate the equation correctly. The rotation has to be applied to both sides of the equation since both the $x$ and the $z$ coordinates are affected by it.

You’ve got $m={z_1-z_0\over x_1-x_0} = \tan\theta$, and so $\cos\theta = {1\over\sqrt{1+m^2}}$ and $\sin\theta = {m\over\sqrt{1+m^2}}$. Making the substitution $x\to z\sin\theta+x\cos\theta$, $z\to z\cos\theta-x\sin\theta$ for both variables, the rotated formula for the Fresnel zone is then $$z\cos\theta-x\sin\theta = \sqrt{{\lambda (x\cos\theta+z\sin\theta)(d-x\cos\theta-z\sin\theta) \over d}}. \tag 1$$ Squaring both sides, substituting the above expressions for the sine and cosine of the rotation angle and rearranging produces the more conventional-looking equation $${\lambda+dm^2\over d+dm^2} x^2 - 2{m(d-\lambda)\over d+dm^2} xz + {d+\lambda m^2 \over d+dm^2} z^2 - {\lambda\over\sqrt{1+m^2}} x - {\lambda m \over \sqrt{1+m^2}} z = 0. \tag 2$$ You could solve this for $z$, but I wouldn’t bother since this ellipse can be plotted directly.

Equation (2) isn’t the complete solution, of course, since the original equation of the Fresnel zone that you gave assumes that one point is the origin and the other is at $(d,0)$. For a complete solution, you will also need to translate the origin to the arbitrary point $(x_0,z_0)$ after rotation by making the further substitutions $x\to x-x_0$ and $z\to z-z_0$ in equation (2). Since you’re working with a slope $m$, this also doesn’t cover the case when $x_0=x_1$, but the equation of the ellipse for that case is obtained by simply swapping the roles of $x$ and $z$.

I think that I would’ve started by rewriting the equation of the Fresnel zone in the more conventional form $$\lambda x^2 + d z^2 -\lambda d x = 0. \tag 3$$ Making the same substitutions in this equation gives $${\lambda (m(z-z_0)+(x-x_0))^2 \over 1+m^2} + {d ((z-z_0)-m(x-x_0))^2 \over 1+m^2} - {\lambda d (m(z-z_0)+(x-x_0)) \over \sqrt{1+m^2}} = 0 \tag 4$$ as the equation of the Fresnel zone for an arbitrary pair of points (that aren’t aligned vertically).

It’s possible to incorporate the $x_0=x_1$ case by deriving the required rotation and translation directly from the coordinates of $p_0$ and $p_1$. Without going into detail, the resulting equation will be, in matrix form, $\mathbf x^TM^TCM\mathbf x=0$, where $$C = \begin{bmatrix}\lambda&0&-\frac{\lambda d}2\\0&d&0\\-\frac{\lambda d}2&0&0\end{bmatrix}$$ is the matrix corresponding to the original equation (3) and $$M = \begin{bmatrix} x_1-x_0 & y_1-y_0 & x_0(x_0-x_1)+y_0(y_0-y_1) \\ -(y_1-y_0) & x_1-x_0 & x_0y_1-x_1y_0 \\ 0&0&d\end{bmatrix}$$ is the inverse of the transformation that maps the “standard” position of the Fresnel zone equation onto the given points. The resulting expression is, of course, much more complex than equation (4).