I want to calculate the slope of the tangent at one point of an ellipse whose centre is shifted towards the coordinates $(x_c;y_c)$ and also rotated by an angle $\alpha$ around its centre. Now, I have already found the tangent formula for a simple ellipse without shift and rotation (from Wikipedia). $$\frac{x\cdot x_1}{a^2}+\frac{y\cdot y_1}{b^2} = 1 \iff y = b^2\frac{a^2-x\cdot x_1}{a^2\cdot y_1}$$
where $(x_1;y_1)$ are the coordinates of the point on the ellipse (which I have already calculated) and $a$ and $b$ are the two semi-axis of the ellipse.
Now I was thinking about how I may use this formula for my case. What I came up with is:
- Calculate two points on the non-transformed tangent (that I get from the formula above).
- Rotate both points by the ellipse-angle around $(0,0)$
- Shift both points by $(x_c;y_c)$
- Draw a new tangent through the two transformed points.
Is this a valid way to do it or do I have to do the whole derivation of the tangent formula for the more complex ellipse equation?
Ok I made it work myself. Here is how I did it:
Abbreviations i use:
FTE - Fully transformed ellipse (rotated by angle u, shifted by xc on the x-axis and yc on the y-axis) OE - Origin ellipse (not rotated, not shifted, meaning its center is at 0|0) TP - Tangent point (point on the ellipse, where tangent and ellipse intersect)
The two points now define the tangent to the FTE at the original TP. You can get the straight line equation using
$$m=\frac{y1-y2}{x1-x2}, b=y1-m*x1$$.
The order of the transformations are important. For the transformation of FTE to OE first translate then rotate and for the back transformation first rotate then translate.
Appendix:
Formula for the rotated ellipse:
$$\frac{((x-x_c)*Cos(u)+(y-y_c)*Sin(u))^2}{a^2}+\frac{(-(x-x_c)*Sin(u)+(y-y_c)*Cos(u))^2}{b^2}=1$$
The formulas for finding the intersection between the FTE and the straight line I calculated with Mathematica. They came out very complex. Maybe they can be simplified somehow, but I won't do that since they work for my needs. I would like to ask mods to not modify these with latex. The reason is that in my opinion these should be used as black boxes. Plug values in, get values out. So you can just copy paste these into your project and this is easier in plain-text form.
Variables:
c - Intercept of straight line
xg1, yg1 - Coordinates of first intersection point
xg1
yg1
xg2
yg2