Finding an ellipse tangent to a circle when its center and semi-minor axis are given
The circle.
Solve[x^2 + y^2 == 19^2, y]
{{y -> -Sqrt[361 - x^2]}, {y -> Sqrt[361 - x^2]}}
D[Sqrt[361 - x^2], x]
-(x/Sqrt[361 - x^2])
The ellipse.
With[{b = 3/2},
Simplify[Solve[x^2/a^2 + (y - 15)^2/b^2 == 1, y], a > 0]]
{{y -> 15 - (3 Sqrt[a^2 - x^2])/(2*a)}, {y -> 15 + (3 Sqrt[a^2 - x^2])/(2*a)}}
D[15 + (3 Sqrt[a^2 - x^2])/(2 a), x]
-((3 x)/(2 a Sqrt[a^2 - x^2]))
The points of tangency are the points where the two curves intersect and have the same derivatives. We make use of this to find a
.
Solve[
{Sqrt[361 - x^2] == 15 + (3 Sqrt[a^2 - x^2])/(2 a),
x/Sqrt[361 - x^2] == (3 x)/(2 a Sqrt[a^2 - x^2])},
{a, x}]
Now we can draw the figure.
With[{a = 1/2 Sqrt[1/2 (553 + 5 Sqrt[10153])], b = 3/2},
Graphics[{Circle[{0, 0}, 19], Circle[{0, 15}, {a, b}]},
PlotRange -> {12 {-1, 1}, {13, 19.2}}]]
Update
For the record, here is the computation of the two angles θ1
and θ2
that allow the section of the ellipse lying above the two tangents points to be clipped out of the figure.
a1 = N[(1/2) Sqrt[(1/2) (553 + 5 Sqrt[10153])]];
b1 = 1.5;
x-coordinates of the points of tangency.
x1 = -N[Sqrt[-(10153/288) + (467 Sqrt[10153])/288]]; (* left *)
x2 = -x1; (* right *)
Translating the ellipse to the origin to get y1
.
y1 = N[Sqrt[361 - x2^2] - 15];
This next calculation is a little tricky. Because of the way Mathematica draws ellipses by stretching circles, it is necessary to reverse the stretch of the y-commponent when computing the angles.
θ = ArcTan[x2, y1 a1/b1]];
θ1 = π - θ;
θ2 = θ + 2 π;
Graphics[
{Circle[{0, 0}, 19],
Circle[{0, 15}, {a1, b1}, {θ1, θ2}],
Red, Point[{{x1, 15 + y1}, {x2, 15 + y2}}]},
PlotRange -> {12 {-1, 1}, {12.9, 19.2}}]
My answer is totally with reference to the m_goldberg answer, but with some changes because some steps were manually entered and I want to make everything automatic.
Some unwanted messages will appear, so I'll leave clean outputs
ClearAll["Global`*"]
Off[Solve::ratnz]
Off[General::ivar]
A general function for the circle equation was created. The Circle
function already exists, but the output of this function will give me the equation as a function of x
.
eqCircle[x0_, y0_, r_] :=
Solve[(x - x0)^2 + (y - y0)^2 == r^2, y] /. Rule -> Set // Last
I will highlight the variable r
because it will be used in function as in graphics.
r = 19;
eqCircle[0, 0, r]
$\left\{\sqrt{361-x^2}\right\}$
g1 = Graphics[{Thickness[0.006], Circle[{0, 0}, r]}]
As the variable y
received a value through eqCircle
function I will save its value in another variable and clear the memory so that the variable y
receives another value when passing through eqEllipse
function.
eqC = y
Clear[y];
$\left\{\sqrt{361-x^2}\right\}$
The points of tangency are the points where the two curves intersect and have the same derivatives. Below is the derivative of the circle
equation.
dy1 = D[eqC, x]
$-\frac{x}{\sqrt{361-x^2}}$
I will highlight the variable b
because it will be used in the function as in graphics.
I will highlight the variable y0Ellipse
because it will be used to get the variable $\theta$
b = 1.5;
x0Ellipse = 0;
y0Ellipse = 15;
eqEllipse[x0_, y0_, a_, b_] :=
Solve[(x - x0)^2/a^2 + (y - y0)^2/b^2 == 1, y] /. Rule -> Set // Last
eqEllipse[x0Ellipse, y0Ellipse, a, b]
$\left\{1.5 \left(\frac{\sqrt{a^2-1. x^2}}{a}+10.\right)\right\}$
As the variable y
has received a value through eqEllipse
function I will save its value in another variable and clear the memory.
eqE = y
Clear[y];
$1.5 \left(\frac{\sqrt{a^2-1. x^2}}{a}+10.\right)$
The points of tangency are the points where the two curves intersect and have the same derivatives. Below is the derivative of the ellipse
equation.
dy2 = D[eqE, x]
$-\frac{1.5 x}{a \sqrt{a^2-1. x^2}}$
The solution to the question is here
Using Solve
by matching the two specific functions and their derivatives to this scenario I have created the values of the variables a
and x
.
Just a remark: At this point only I improved what m_goldberg
answered by adding the expressions && a > 0 && x > 0
to filter the expected results.
Solve[{eqC == eqE, dy1 == dy2 && a > 0 && x > 0}, {a, x}] /.
Rule -> Set
$\left( \begin{array}{cc} 11.4935 & 11.3197 \\ \end{array} \right)$
To obtain the angles
that create the section of the ellipse, simply find the angle formed between eqE-y0Ellipse
and x
. The variable x
was obtained by the above resolved.
eqE
y0Ellipse
x
θ = ArcTan[x, eqE - y0Ellipse]
$15.2599$
$15$
$11.3197$
$0.0229571$
Here is a chart to make it easier to understand
Enlarging the image above
g2 = Graphics[{Thickness[0.003],
Circle[{0, 15}, {a, b}, {2 Pi + θ, Pi - θ}]}]
Show[g1, g2]