필터 지우기
필터 지우기

How to find a tangent point from a circle?

조회 수: 7 (최근 30일)
DhanaLakshmiR
DhanaLakshmiR 2018년 1월 3일
댓글: DhanaLakshmiR 2018년 1월 3일
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
KSSV 2018년 1월 3일
x3,y3,z3=[230000 16000 200];
The above line is not valid..please check your code.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 1월 3일
  댓글 수: 1
DhanaLakshmiR
DhanaLakshmiR 2018년 1월 3일
Thanks a lot..Thank you for your Reference..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by