Find equation of circle/ellipse through two points resting in quadrant 1 (with restrictions)

I'm trying my best to figure a circle problem out! Consider a circle, or an ellipse (a circle scaled either on the local X or Y axis). For any two points in quadrant 1, what is the equation of the circle/ellipse such that it passes through both points, having those points rest on quadrant 1 of the circle/ellipse if it was a unit circle, or in other words, have it rest on the arc from $$0$$ to $$\pi/2$$. I figure there's likely an infinite number of solutions depending on the scale, and that's desired, because I'm looking to have input parameters: point1X, point1Y, point2X, point2Y, circleScaleX, circleScaleY. It's possible that there's still more than one solution with those inputs, and if so, what else do I have to constrain?

The point of what I'm trying to accomplish isn't really to get one solution anyway, but to get a variable shape arc between the two points, being able to tweak it until it looks good. So even if there's a third circle variable of some kind to set to result in the one solution I need to paint the arc to the screen, that's cool with me.

Now that I think about it, I think a constraint for the points is that point1X < point2X and point1Y > point2Y so that we always result in the arc "roundness" pointing out in the positive direction of $$y = x$$.

I should note that it's a requirement that the arc is composed of a segment of a circle or ellipse, I can't use something like Bézier curves.

Thanks ahead of time, all the best!

• An axis-aligned ellipse centered at $(x_0, y_0)$ with semi-axes ("radiuses") $r_x$ and $r_y$ fulfills$$\left(\frac{x - x_0}{r_x}\right)^2 + \left(\frac{y - y_0}{r_y}\right)^2 = 1$$so whether your question has an answer or not, depends on whether circleScaleX and circleScaleY correspond to the semiaxes or not. Another way to put that is "If the ellipse you search has axis-aligned bounding box with width 2*circleScaleX and height 2*circleScaleY, then there is a solution; otherwise, we do not have enough information, and have infinitely many possible solutions, and no way to choose". Jun 29 '21 at 19:36
• As pointed out in the answer below, for a given circleScaleX and circleScaleY you might have point1X < point2X and point1Y > point2Y and yet the two points might still not be on the arc from $0$ to $\frac\pi2.$ An alternative set of input would be the coordinates of both points, where point1X < point2X and point1Y > point2Y, and two angle values, $0 \leq \theta_2 < \theta_1 \leq \frac\pi2$, where $\theta_1$ and $\theta_2$ are the values you plug into the parametric formula of the ellipse. This guarantees both points are first quadrant. Jun 30 '21 at 11:39

First, divide point1X, point2X by circleScaleX and point1Y, point2Y by circleScaleY. This rescales the horizontal and vertical dimensions to transform the problem into finding a circle of radius 1. Let $$P_1 =(x_1, y_1), P_2 = (x_2, y_2)$$ be the transformed points, labeled with $$x_1 \le x_2$$.

Any circle passing through $$P_1$$ and $$P_2$$ must have its center on the perpendicular bisector of the line segment between them. If $$x_1 = x_2$$, the circle will have one point in the first quadrant, and the other in the fourth quadrant, contrary to your conditions. In this case there is no solution.

More generally, set $$r = \frac12\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}$$ to be half the distance between $$P_1$$ and $$P_2$$. [Edit:] From the point of view of the center of the circle, the chord $$\overline{P_1P_2}$$ can be viewed as a bar of fixed length that can be slid around the circle to handle various configurations of $$P_1$$ and $$P_2$$. But if both are to be in the first quadrant, then the counterclockwise point $$P_1$$ can be slid at most to straight up from the center, and the clockwise point $$P_2$$ can be slid at most to straight right of the center. $$P_1$$ straight up is the configuration with the smallest difference between $$y_1$$ and $$y_2$$, and $$P_2$$ straight right is the configuration with the smallest difference between $$x_1$$ and $$x_2$$.

A little playing with right triangles gives the conditions for both points to be in the first quadrant as $$2r^2 \le x_2 - x_1 \\2r^2 \le y_1 - y_2$$ [End of Edit] Note that this requires $$r \le \frac{\sqrt 2}2$$, and $$\overline{P_1P_2}$$ must have negative slope.

Assuming this is true, the circle center will lie on the perpendicular bisector of $$\overline{P_1P_2}$$ a distance of $$\sqrt{1 - r^2}$$ to the lower left of the midpoint. Let $$q = \frac{\sqrt{1 - r^2}}{r}$$. Then the center is given by

$$C = \left(\frac {x_1 + x_2 +q(y_2-y_1)}2, \frac {y_1 + y_2 +q(x_1-x_2)}2\right)$$

(Note that it is $$y_2 - y_1$$ on the $$x$$ coordinate formula, and $$x_1 - x_2$$ on the $$y$$ coordinate formula - the reversal of the indices is needed.)

Finally, multiply the $$x$$-coordinate of $$C$$ by circleScaleX and the $$y$$-coordinate of $$C$$ by circleScaleY, to convert it back to the unscaled problem, where the circle becomes the ellipse $$\frac{(x - x_C)^2}{r_x^2} + \frac{(y - y_C)^2}{r_y^2} = 1$$

where $$(x_C, y_C)$$ are the converted coordinates of $$C$$, and $$r_x, r_y$$ are circleScaleX and circleScaleY.

• I was going to post an adaptation of this answer but I think you've already covered that angle. Nice! Jun 30 '21 at 11:30
• @DavidK - I'm glad I got it fixed before you saw it! Jun 30 '21 at 13:54
• Thank you for your help! I haven't had the opportunity to try/implement this yet but I will surely come back to it soon enough. :) Jul 7 '21 at 13:09