Height of one of the intersection of a line and a circle in MATLAB

1 次查看(过去 30 天)
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))

采纳的回答

darova
darova 2019-8-29
Here is what i achieved
Equation of a circle:
Equation of a line:
img1.png
  4 个评论
Anish Pradhan
Anish Pradhan 2019-8-30
Hey, I understood what was the problem. When v is close to r, things get difficult about . Actually not difficult, but the actual quantity that I want is slightly more complex. Thanks for your help.
darova
darova 2019-8-30
I wanna be the first on the rating list here. Can you please help me and accept the answer?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by