Surface and Line interaction point
조회 수: 24 (최근 30일)
이전 댓글 표시
Hello
I have two pints and I need to find the surface passing them and then investigate even a line that passes new points A nad B have an interaction with the surface or not?
I have to add that all my numbers are positive and I do not have a negetive integer so I can not use "fzero" function since the root of the function is where fun(x) changes sign.
I write the below code as far and have problem for the intersection part.
Thanks for any help.
%Creating surface in matlab
x=[-1;5];
y=[1;1];
[X,Y]=meshgrid(x,y);
z=[0 0; 2 2];
S=surf(X, Y, z)
hold on
stem3(x, y, z, '--*m')
% A and B cordinates
XN =[ 0.5; -0.7];
YN=[-0.5;1.5];
ZN=[-1;1.5];
hold on
scatter3(XN,YN,ZN);
A =[XN(1) YN(1) ZN(1)];
B =[XN(2) YN(2) ZN(2)];
plot3(XN,YN,ZN);
% check if the line passinng A and B has an interaction with surface "S" or not?
댓글 수: 2
채택된 답변
Jyotsna Talluri
2019년 8월 5일
Hi,
As you know coordinates of the surface ,first determine the normal vector to the surface
From your code the coordinates are
p0=[-1 1 2];
p1=[5 1 2];
p2=[-1 1 0];
p3=[5 1 0];
n=cross(p0-p2,p0-p3);
gives the normal to the plane of the surface.
The function plane_line_intersect in the below link of file exchange determines the point of intersection of surface and the line
As argument V0 can be any point in the plane ,it can be p0,p1,p2,p3;
You declared line end points as A and B
Hence, call the function plane_line_intersect(n,V0,A,B) by passsing the arguments
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!