I am a programmer but my maths skills are poor, I find geometry, trigonometry and algebra etc. difficult to grasp. But I have had a look online for the solution to this problem to no avail, I hope someone can help.
I have an elliptical arc into which I am drawing line segments, however on occasion I need to draw arcs that follow the curve of the arc between the line segments, please see the blue lines in the picture:
Is there a formula that I can use that will tell me the degree positions where these blue arc sections should start and end. I know the x position of the line segments (and the two radii of the ellipse and the start and end x position of the ellipse)?
I will make a guess that the graphics program renders an ellipse by stretching or shrinking a circle by different amounts in the horizontal and vertical directions, and that the angles that determine the start and end of each arc are measured on the circle before it is stretched/shrunk. That is, the direct input to the graphics function uses angles like the angle named $\theta$ in Figure 14 on this page to decide where to start or stop an arc.
I also assume that the green arc represents an arc from $0$ degrees (at the right end) to $180$ degrees (at the left end), and that the horizontal coordinates of points are increasing as we go to the right.
Let the horizontal radius of the ellipse be $a$ and let the center of the ellipse have horizontal coordinate $x_C.$ For a vertical line at horizontal coordinate $x_1,$ let $$ \theta = \arccos\left(\frac{x_1 - x_C}{a} \right), $$ where $\arccos(\cdot)$ is the inverse cosine function. Then $\theta$ is the angle that the graphics function takes to describe the point where the vertical line meets the ellipse.
Note that in many (if not all) math libraries that have an inverse cosine function, the output of the function is in radians rather than degrees. If you really need degrees for your graphics input, you may need to multiply by $\frac{180}{\pi} \approx 57.2957795131.$
In case you do not have an inverse cosine function, there are workarounds that use either the inverse tangent function or inverse sine function, but this problem becomes a lot more difficult if you have no access to any inverse trigonometric functions.