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

1 回表示 (過去 30 日間)
sita
sita 2015 年 2 月 3 日
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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by