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 件のコメント
Geoff Hayes
Geoff Hayes 2021 年 9 月 29 日
sparsh - I'm not sure how your code is related to finding the tangents of the circle. What exactly are you asking help for?
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?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by