given a circle plot all possible tangents

조회 수: 2(최근 30일)
sparsh garg
sparsh garg 2021년 9월 28일
댓글: sparsh garg 2021년 9월 29일
So as the question says I would like to obtain all the tangents to a circle.
I came across the question mentioned below
but after executing it this is what i get
The circle looks like this
enclosed are the points of the circle,its center and radius info as well as the orignal set of points on which this was drawn
the code for drawign circle is
function Circ = circle(xc,yc,R,flag)
theta=0:pi/270:2*pi;
xcircle = R*cos(theta')+xc;
ycircle = R*sin(theta')+yc;
dxda=-R.*sin(theta);
dyda=R.*cos(theta);
dydx=dyda./dxda;
if flag
plot(xcircle,ycircle);
hold on;
end
Circ=[xcircle,ycircle];
Circ=Circ';
% for i=1:size(Circ,2)
% pt=[xcircle(i) ycircle(i)];
% intcpt = pt(2) - dydx(i).*pt(1); % Calculate Intercept
% xvct = pt(1)-1:pt(1)+1; % ‘x’ Vecor For Tangent
% tngt = dydx(i).*xvct + intcpt; % Calculate Tantent
% plot(pt(1),pt(2),'gp');
% plot(xvct,tngt);
% hold on;
%
% end
end

답변(1개)

Geoff Hayes
Geoff Hayes 2021년 9월 28일
Sparsh - the code from https://www.mathworks.com/matlabcentral/answers/258780-how-to-plot-tangent-line-from-specified-point-to-a-circle plots the tangent for one particular point on the circle. When I run the code (provided in the answer) I do not see the first image that you included above but instead see the tangent line at a single point. If you need to show all tangents, then you would need to update the code to loop through all points on the circle and draw the tangent for each.
As for your second image, how did you generate that? I almost think there is a different question being asked here.
  댓글 수: 4
sparsh garg
sparsh garg 2021년 9월 29일
Hey geoff the code in the comment was meant for reproducing the second image.
What I want here is as we go along the R,we will have several circles,the tangents to those circles will be intersecting the curves shown in the second image at some point.If I can find where exactly those tangents are intersecting the curves,then i find the line that is perpendicular to a tangent and which connects those two intersections.
Also,since you took the time to comment,let's say we have a set of x y points that describe the circle ,if I wanted to visualize the diameter of the circle is there any way to do that.
I have info about the center and the radius,one way is for all points i simply connect them,and then the one which has the largest distance wil be the diameter.
Let me know if you have any questions.
For sake of simplicity
When I do a for loop on all the points in the circle and plot a tangent the code becomes slow and the result is not good quite similar to the one shown in figure 1.
DLTR
First I run this code to compute a circle that lies along the 2 curves
load('r')
load('centers')
load('radii')
plot(Fp(1,:),Fp(2,:));set(gca,'YDir','reverse');
hold on;
cent=CenterPoints(1,:);
cir=circle(cent(1),cent(2),radii(:,1))
Now I need to find the tangents to those circles so that I can connect the points at which the tangent intersects the curves.
If the question still seems confusing,then are there any matlab tools that allows me to visualize the diameter of a circle?

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by