How can I draw a tangent line from a given point to a circle in Matlab
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Suhas
il 4 Set 2013
Commentato: Roger Stafford
il 22 Mag 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 Commenti
dpb
il 4 Set 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...
Risposta accettata
Roger Stafford
il 5 Set 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 Commenti
Antonio Cantiani
il 21 Mag 2016
I would like to understand the mathematics behind this. Can someone explain it, please?
Roger Stafford
il 22 Mag 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!