How can I draw a tangent line from a given point to a circle in Matlab
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Suhas
el 4 de Sept. de 2013
Comentada: Roger Stafford
el 22 de Mayo de 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 comentarios
dpb
el 4 de Sept. de 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...
Respuesta aceptada
Roger Stafford
el 5 de Sept. de 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 comentarios
Antonio Cantiani
el 21 de Mayo de 2016
I would like to understand the mathematics behind this. Can someone explain it, please?
Roger Stafford
el 22 de Mayo de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!