How to find a tangent point from a circle?
6 ビュー (過去 30 日間)
古いコメントを表示
I have a code to find a tangent point from a circle.I have used the circle radius as 2000.For all the points on the circle it will find the tangential point for the given radius. But when the point lies exactly on the same line then the vector point will be NAN for the given radius,if the radius changed then the vector is having answer why?Here i have displayed code for finding points.kindly give answer.
x1=200000;y1=15000;
x2=350000;y2=20000;
z1=200;z2=200;
x3,y3,z3=[230000 16000 200];
Radius=2000;
a11=((x2-x1)^2+(y2-y1)^2+(z2-z1)^2);
b11=2*(((x2-x1)*(x1-x3))+((y2-y1)*(y1-y3))+((z2-z1)*(z1-z3)));
c11=x3.^2+y3.^2+z3.^2+(x1^2)+(y1^2)+(z1^2)-2*((x3*x1)+(y3*y1)+(z3*z1))-(Radius*Radius);
condn1=(b11*b11)-(4*a11*c11);
condition=abs(condn1);
t=(-b11+(sqrt((condition))))/(2*a11);
t1=(-b11-(sqrt((condition))))/(2*a11);
Xi=x1+(x2-x1)*t;
Yi=y1+(y2-y1)*t;
Zi=z1+(z2-z1)*t;
Xf=x1+(x2-x1)*t1;
Yf=y1+(y2-y1)*t1;
Zf=z1+(z2-z1)*t1;
v1 = [Xi-x3;Yi-y3;Zi-z3];
radius = norm(v1);
v2 = [Xf-x3;Yf-y3;Zf-z3];
v3 = cross(cross(v1,v2),v1);
v3 = radius*v3/norm(v3);
t = linspace(atan2(norm(cross(v1,v2)),dot(v1,v2)),0,5);
vec = v1*cos(t)+v3*sin(t);
XVec=vec(1,:)+x3
YVec=vec(2,:)+y3
ZVec=vec(3,:)+z3
1 件のコメント
KSSV
2018 年 1 月 3 日
x3,y3,z3=[230000 16000 200];
The above line is not valid..please check your code.
採用された回答
KSSV
2018 年 1 月 3 日
Refer this link for what you want: https://in.mathworks.com/matlabcentral/answers/258780-how-to-plot-tangent-line-from-specified-point-to-a-circle
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!