intersection point between line and circle and draw tangent at that intersection point

조회 수: 1 (최근 30일)
Hi, please find below code mentied.i am trying to estimate a circle area by drawing tangents on circle.I need to draw a line from a point(in or out of circle) and draw tangent at intersection point.If i have point inside circle how to draw a line and find where it touches the circle.
x1=5; y1=5; r = 10; t = 0 : .1 : 2*pi; x = r * cos(t) + x1; y = r * sin(t) + y1; hold on; plot(x, y);
cnt=0; for l=1:20
x2=20;
y2=10;
%line
x3=randint(1,1,[-15 15]);
y3=randint(1,1,[-15 15]);
v1=rand(1);
v2=rand(1);
syms s
eq=((x3+s*v1)-5).^2+((y3+s*v2)-5).^2-r.^2;
sval=solve(eq,s)
ansv= vpa(subs(eq,sval))
if(ansv==0)
svale(l,:)=vpa(sval);
line([x2,x3],[y2,y3])
%pointvals(l,:,:)=
cnt=cnt+1;
end
hold off
end
Please help me
Thanks, Sita

답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by