I have a line of length $r$. From each end, I am drawing two circles of radius $v$ where $v<r<2v$. Now, I am drawing a line through one end, cutting through the intersection lens area with a slope of $\Phi$. Now, Fig. 1 describes the construction. I want to find the height of the first intersection point (G in the Fig. 1). From what I understand, when I am changing $\Phi$ from $0$ to $\cos^{-1}(\frac{r}{2v})$ (basically sweeping from the x-axis to the upper intersection point of two circles (D in the Fig. 1)), the height of the point G would be equal to $\sqrt{v^2-\frac{r^2}{4}}$ (the length of CD in Fig. 1).
Now, I know how to do this. I calculated the intersection of $x^2+y^2=v^2$ and $y=(x+r) \tan(\Phi)$ . The solution for $y$ or height comes out to be $y_0=-\sin\Phi\left[\sqrt{v^2 - r^2\sin^2\Phi}-r\cos\Phi\right]$. My problem is, whenever I am putting this in MATLAB, when $v>\frac{r}{\sqrt{2}}$, the plot of $y_0$ doesn't reach $\sqrt{v^2-\frac{r^2}{4}}$ even when $\Phi =\cos^{-1}(\frac{r}{2v})$. I cannot understand where the problem is. Let me know if you can. My simplistic MATLAB code is posted below.
v=18;
r=24;
np=50;
alpha=acos(r*0.5/v);
Phai=linspace(0,alpha,np);
ynot=[];
xnot=[];
C=[];
for i=1:np
C(i)=sqrt(v^2 - (r*sin(Phai(i))).^2);
xnot(i)=-(r*(sin(Phai(i))).^2) - C(i).*cos(Phai(i));
ynot(i)=-sin(Phai(i)).*(C(i)-r*cos(Phai(i)));
end
figure(6)
plot(ynot)
hold on
plot(linspace(0,sqrt(v^2 - 0.25*r^2),np))
The quadratic equation you solve to get $y_0$ has two roots since the line with the slope angle $\Phi$ crosses the circle twice. The solution you use, as far as I see, gives you the lower in $y$ solution. However, given your values $v$ and $r$ the intersection of the circles corresponds to the second solution of the quadratic equation, that is more to the right and has the bigger $y$. Just plot two circles with your $r$ and $v$.
You have to use the lower in $y$ solution (that is in your question) when $2v^2\le r^2$, and the upper in $y$ solution otherwise, that is $$y_0(\Phi,r,v) = \sin\Phi\left[\sqrt{v^2 - r^2\sin^2\Phi}+r\cos\Phi\right].$$