Find coordinates for rectangle with 2 corners that border a path, 1 known corner and 1 known side.

Consider the image above. DEGP is a rectangle that I'm trying to draw programmatically so I need the coordinates of the points.

What's known is this:

• The coordinates of D
• The coordinates of the inside path that P and G are on (semi-circles with straight segments, nothing too weird).
• DE is 20 (as is PG, therefor)
• D is such that a rectangle like this will exist, D will never be lower than C or such that PG is either entirely on the straight or entirely on the semi-circle.

I can't seem to figure out how to get the coordinates of E or G or P because they're all dependent on each other. I tried to draw this by saying that a line from D straight down to AB should be equal to EA, but that gives a wonky result shown below:

Below is how I would do it if PG was entirely on the semi-circle:

So I'd use the symmetry that the rectangle now has over line AQ to find E and draw DP and EG perpendicular until they meet the semi-circle.

EDIT: I originally tagged this algebraic-geometry and I'm coming back to that with a possible approach to solve this:

The semi circle over CJ can be described as $x=-\sqrt{12.5^2-y^2}+\Delta AD$

What formula would describe the path of G as we rotate the rectangle around D and stretch DP (and thus EG) to have P be on the path. If I have that formula, I could equate it to the formula for the semi-circle to determine for which y point G is equal to a point on the semi-circle.

Is this a feasible approach?

• This does not seem a trivial problem at all. Are there any restrictions on the choice of $D$, or do you know a priori that $D$ is chosen such that a rectangle of the type you have shown exists? How far have you gotten with any calculations? The way I would try and tackle this is to find the points $G$ and $P$ such that the line $GP$ is orthogonal to $DP$. Once you have found these points then $E$ is automatically defined. Have you tried something like this already? Sep 21, 2013 at 18:00
• You know a priori that such a rectangle exists. If D is such that PG would be entirely on the straight or entirely on the semi-circle, the problem is much easier and would be solved by a different calculation. Furthermore, the ovals actually represent a race-track, so if D is inside the inner oval or outside the outer oval, the calculation wouldn't be carried out. So far I've tried to split the rectangle into 2 triangles with line DG so I could maybe use trigonometry. But I'm unsure how to get the angle EDG from the DeltaY and DeltaX for D and C as those points are known. Sep 21, 2013 at 22:52
• (Edited the question with more info and example if PG is entirely on the semi-circle) Sep 21, 2013 at 23:48
• There is only one degree of freedom here, the position of $P$ on the inner path. This determines $G$ as the point on the path counterclockwise from $P$ with $|PG|=20$ (this is unique as long as the diameter $|CJ|\ge20$). Then the only thing left to solve for is the condition that $PD\perp PG$.
– user856
Sep 22, 2013 at 1:06
• I don't see how the position of P is a degree of freedom as it is constraint by the fact that PD has to be equal to EG for it to be a rectangle. For every valid position of D (which is known) there really is only one possible rectangle. CJ is and will always be 25, coordinates and measurements of the inner path are fully known. Sep 23, 2013 at 23:59