I'm writing a program to draw elliptical arc, the input information as title says
- Start point
- Start angle
- Sweep angle
- X radius
- Y radius
What I need is to find the center and the end point of that arc.
Any help is appreciated
I'm writing a program to draw elliptical arc, the input information as title says
What I need is to find the center and the end point of that arc.
Any help is appreciated
Here is how I approach this problem. Notation: subscripts $s,c,e$ are the start, center, and end points, the major and minor semi-axes $(X,Y)$ are $(a,b)$, and the sweep angle is $\Delta\theta$.
An ellipse can be represented in the complex plane parametrically as
$$z=a\cos t+i~b\sin t,\quad t\in[0,2\pi]$$
Note that $t$ is not the polar angle. Now, since $z_s,~\theta_s$ are given, we can find
$$ \theta_s=\tan^{-1}\frac{b\sin t_s}{a\cos t_s}\\ t_s=\tan^{-1}\left(\frac{a}{b}\tan\theta_s\right) $$
Similarly, without knowing $z_e$ yet, we can find
$$ \theta_e=\theta_s+\Delta\theta=\tan^{-1}\frac{b\sin t_e}{a\cos t_e}\\ t_e=\tan^{-1}\left(\frac{a}{b}\tan\theta_e\right) $$
We then have the location of the end point, to wit,
$$z_e=a\cos t_e+i~b\sin t_e$$
There are two possible meanings to the center point. It might be taken as the center of sweep angle, or the center of the arc length. For the former, we can find the solution as we did for the end point. For the latter, we will need solutions in terms of the incomplete elliptic integral. Here is the analysis.
The arc length in the complex plane is given by
$$s=\int_{t_s}^{t_e} |\dot z|~dt$$
Then
$$ \begin{align} &z=a\cos\theta+ib\sin\theta\\ &\dot z=-a\sin\theta+ib\cos\theta\\ &|\dot z|=\sqrt{a^2\sin^2\theta+b^2\cos^2\theta}=b\sqrt{1-k^2\sin^2\theta}\\ &k^2=\frac{b^2-a^2}{b^2} \end{align} $$
And finally,
$$ \begin{align} s &=\int_{t_s}^{t_e} |\dot z|~dt\\ &=b\int_{t_s}^{t_e}\sqrt{1-k^2\sin^2\theta}\\ &=b\left[\text{E}(k^2,t_e)-\text{E}(k^2,t_s) \right] \end{align} $$
where $\text{E}(k^2,\phi)$ is the incomplete elliptic function. In order to get $tc$ and the $z_c$ we need to first iterate to find $t_c$ from
$$\frac{s}{2}=b\left[\text{E}(k^2,t_c)-\text{E}(k^2,t_s) \right]$$
Then
$$z_c=a\cos t_e+i~b\sin t_c$$
Obviously, this is not a walk in the park.