Start and end point of a rotated ellipse I have the data of an incomplete ellipse and I need to retreive the minimun information in order to describe an elliptical arc. In particular following are my ellipse data:


*

*Major axis vector (x, y)

*Major/minor axis ratio

*Start angle

*End angle

*Center point (x, y)


And for the arc I need the following information:


*

*Start point (x, y)

*End point (x, y)

*Radius X

*Radius Y

*Rotation angle


What equations I need to use in order to get this data?
Following is an example. Given this ellipse:


*

*Major axis vector = (-120, -185)

*Major/minor axis ratio = 0.267

*Start angle = 0 deg

*End angle = 180 deg

*Center point = (0, 0)


The ellipse is:

With start point in (-120, -185) and end point in (120, 185).
I tried by using the classic ellipse equation but it works with some ellipses and not for other (like for example the above one).
 A: Suppose we start with these (generalized) input data:


*

*Center point = $(x_0, y_0)$

*Major axis vector = $(a_x, a_y)$

*Major/minor axis ratio = $k$

*Start angle = $\theta_1$

*End angle = $\theta_2$


For simplicity of exposition,
I'll assume that angles are given in the same units that are expected as
input by the sine and cosine functions that you will use when
implementing this algorithm.
I will also assume that in both the coordinate systems you work in
(input and output), to rotate a vector that (initially)
points in the direction of the positive $x$-axis
so that it ends up pointing in the direction of the positive $y$-axis,
you would rotate it through a positive angle of $90$ degrees
or $\frac\pi2$ radians.
I will assume that the vector $(a_x, a_y)$ represents the displacement vector
from the center of the ellipse to one end of the major axis.
Then the direction of this vector is $\psi = \text{atan2}(a_y,a_x)$,
where $\text{atan2}(\cdot)$ is the two-parameter arc tangent function
available in many computer math libraries.
The semi-major axis length ("radius X") is then $a = \sqrt{a_x^2 + a_y^2}.$
The semi-minor axis length ("radius Y") is $b = ka.$
There are at least two ways that angular values measured from the center
of an ellipse are used to describe points on the ellipse.
One is the actual angle between the vector from the center to the point
in question and a vector parallel to the major axis.
The other way is to use the so-called eccentric anomaly.
The eccentric anomaly is what you see when someone parameterizes
an ellipse in the form $(x,y) = (a \cos \theta, b \sin \theta).$
One way to tell which of these your graphic library uses is to draw
an ellipse whose minor axis is $0.1$ times the major axis,
starting at an angle of $45$ degrees (or $\frac\pi4$) and
ending at an angle of $135$ degrees (or $\frac{3\pi}4$).
If the library interprets the angles as actual angles, it will draw
an arc whose length is about $20\%$ of the length of the major axis.
If the library interprets each angle as an eccentric anomaly
then the arc length will be about $70\%$ of the length of the major axis.
I'll assume we're using real angles, not eccentric anomaly.
The polar equation for an ellipse centered at the origin,
with axes $a$ and $b$ parallel to
the coordinate axes is
$$ r = \frac{ab}{\sqrt{b\cos^2\theta + a\sin^2\theta}}. \tag 1$$
This gives a parametric equation of the ellipse,
$$ (x(\theta),y(\theta))
 = \left(r(\theta) \cos\theta, r(\theta) \sin\theta\right)
\tag 2$$
with $r(\theta)$ defined by Equation $(1)$.
Recalling that we already computed $\psi$, the direction of the major axis,
we can use the rotation matrix
$$ M = \begin{pmatrix}
       \cos \psi & -\sin \psi \\
       \sin \psi &  \cos \psi)
\end{pmatrix}$$
to "rotate" the ellipse. (If this results in a rotation in the wrong
direction, replace $M$ with its transpose.)
So, translating the ellipse of Equation $(2)$ so its center is at  $(x_0,y_0)$
and rotating it by angle $\psi$ to align the major axis correctly,
we have
$$ (x(\theta),y(\theta))
 = (x_0,y_0) +
  M \left(r(\theta) \cos\theta, r(\theta) \sin\theta\right). 
$$
Plug in $\theta_1$ to get your starting point,
or $\theta_2$ to get your ending point.
Actually I seem to recall that SVG lets you translate and rotate pieces
of the drawing individually, so maybe you could just use Equation $(2)$
to find out where the starting and ending points would be if
the ellipse were centered at $(0,0)$ at an angle of $0$,
then move the resulting arc to where it actually should be.
It's possible that some of this is based on mistaken assumptions about how
the two graphics systems work. If it is a simple mistake such as drawing
the figure upside down or rotating it in the wrong direction,
a judicious change of sign in one of the equations will probably fix it.
I usually end up figuring out that sort of thing by trial and error
(since there are usually only two choices and one will clearly be wrong).
