
Height of one of the intersection of a line and a circle in MATLAB
1 view (last 30 days)
Show older comments
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][1] describes the construction. I want to find the height of the first intersection point (G in the [Fig. 1][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][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][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))
0 Comments
Accepted Answer
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!