How can I draw a tangent line from a given point to a circle in Matlab
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2013-9-4
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...
采纳的回答
Roger Stafford
2013-9-5
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 个评论
Antonio Cantiani
2016-5-21
I would like to understand the mathematics behind this. Can someone explain it, please?
Roger Stafford
2016-5-22
@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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!