How can I draw a tangent line from a given point to a circle in Matlab
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Suhas
am 4 Sep. 2013
Kommentiert: Roger Stafford
am 22 Mai 2016
Hi I am trying to draw a tangent line from a given external point to a circle of known radius and origin as the center
Please help
3 Kommentare
dpb
am 4 Sep. 2013
The obvious is that the radius and the tangent line must be normal to each other so the three points have to form a right triangle...
Akzeptierte Antwort
Roger Stafford
am 5 Sep. 2013
Let P1 be a 1 x 2 row vector of the external point's cartesian coordinates and P2 a similar vector of the circle's center coordinates. Let r be the circle's radius. Then Q1 and Q2 below will be the two possible points of tangency of a line from P1. Q1 is to the right and Q2 to the left as viewed from P1 looking toward P2.
P = P1-P2;
d2 = dot(P,P);
Q0 = P2+r^2/d2*P;
T = r/d2*sqrt(d2-r^2)*P*[0,1;-1,0];
Q1 = Q0+T;
Q2 = Q0-T;
4 Kommentare
Antonio Cantiani
am 21 Mai 2016
I would like to understand the mathematics behind this. Can someone explain it, please?
Roger Stafford
am 22 Mai 2016
@Antonio: This is a brief outline of the derivation of the above expressions. If the points Q1 and Q2 are connected with a straight line, this line will cross the line between P1 and P2 at a right angle by symmetry, and the point Q0 is defined as the point where these lines cross. The four points P1, P2, Q1,and Q0 when connected form three similar right triangles and the expression for Q0 as P2+r^2/d2*P can be deduced from some of the like ratios involved in these triangles. The vector P*[0,1;-1,0] points at right angles to the vector P, and the expression for T which points from Q0 to Q1 can also be derived from these similar triangle ratios, along with the Pythagorean theorem. By symmetry -T points in the opposite direction from Q0 to Q2.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!