Here's a problem I assumed would be easy, but it has melted my brain for a long time and I am not really sure anymore. So I am using cos and sin to draw round curves in a program (it's okay that it's slow). You specify an x length, y length, and angle1 and angle2 with the axises you want the curve to enter and exit (Some angles won't work obviously). So if you say x = 1, y = 1, angle1 = 45, angle2 = 45, the function just draw a straigth line, however with angle1 = 0 and angle2 = 90, it draw a quarter of a circle. The quarter circle works fine if x = 1 and y = 2 as well, but with different values x and y, I simply stretch everything, so the straigth line of with angles 45 have now instead angle atan(0.5) and atan(2). So my idea was to simply find the angles that turns into the correct angles after the stretching. But I've been trying for a few hours, and every time I thought I got closer to the answer it turns out I just got confused.

Detail: the function draws a perfect circle using cos(t), sin(t), where t lies in the interval of the angles, before stretching the curve into the right size.