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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (0)

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by