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

조회 수: 1 (최근 30일)
Anish Pradhan
Anish Pradhan 2019년 8월 29일
댓글: darova 2019년 8월 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