Bounding rectangle of ellipse In a stale branch of the code base I'm working on, I found an interesting algorithm to go from the SVG definition of an elliptical arc, to Bézier curves. This is a question about a small but crucial part that I don't understand.
FYI an updated and fully corrected version of the algorithm is now published on the develop branch of iText 7; it is confirmed to work for all tested scenarios, so I'm only looking for an explanation as to why the angle $\chi$ is calculated as it is.
input: starting point $(x_1, y_1)$, ending point $(x_2, y_2)$, semi-axes $a$ and $b$, and the guarantee that $a$ is parallel to the horizontal axis
intermediate output: a bounding rectangle, a starting angle, and an extent, to be consumed by an established function.
The salient part of the algorithm goes like this, in pseudocode:
$$r_1 = \frac{x_2 - x_1}{-2a}$$
$$r_2 = \frac{y_2 - y_1}{2b}$$
$$\kappa = \arctan{(r_1 / r_2)}$$
$$\lambda = \arcsin{\sqrt{r_1^2 + r_2^2}}$$
$$\chi = \kappa \pm \lambda (+ \pi ?)$$
Then, for all scenarios for $\chi$, try
$$center = (x_1 - a * \cos \chi, y_1 - b* \sin \chi)$$
Once $center$ is known, calculating the bounding rectangle is trivial, and the angles can also be attained with relative ease.
And now the question: I understand most of the algorithm, but I must admit that I have no idea why $\kappa$ and $\lambda$ together form the angle we're looking for.

 A: D. Thomine’s comment beat me to the punch. The parameterization $C+(a\cos t,b\sin t)$ of an ellipse can be understood as the image of the unit circle $(\cos t,\sin t)$ under scaling and translation, and the key to understanding this part of the algorithm is to map everything back to the unit circle.  
So, let $C$ be the as-yet-unknown coordinates of the ellipse center, and let $P_1' = (x_1',y_1') = (x_1/a,y_1/b)-C$ and similarly for $P_2'$. (The unknown $C$’s will cancel and drop out of the calculations pretty quickly.) We then have $(-r_1,r_2)=\frac12(P_2'-P_1')$, i.e., half of the segment $P_1'P_2'$, and $\sqrt{r_1^2+r_2^2}$ is the length of this half-segment. Rotating this vector 90° produces $(r_2,r_1)$, which is the direction of a line through the center of the circle and the midpoint of $P_1'P_2'$. The interpretation of the two angles $\kappa$ and $\lambda$ becomes pretty straightforward with that:

$\chi=\kappa\pm\lambda$ are the angles to $P_1'$ and $P_2'$ (with some ambiguity as to quadrant), which are then the correct inputs to $C+(a\cos\chi,b\sin\chi)$ to obtain $P_1$ and $P_2$.  
It’s also possible to solve for the center of the ellipse more directly: it must lie on one of the intersections of the congruent ellipses centered at $P_1$ and $P_2$. If you subtract the equation of one of these ellipses from the other, you get the equation of a line that passes through the two intersection points. The problem then reduces to the intersection of a line and an ellipse, which can be solved quite readily. The resulting expressions are much more complex than the ones in the algorithm in your code, though.
