Surface and Line interaction point

41 views (last 30 days)
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 Comments
Zarak kh
Zarak kh on 1 Aug 2019
I want to find the (x,y,z) cordinates of the intersection point of the mentioned line and surface, So I will be able to add an "if" clause for the rest of the program.

Sign in to comment.

Accepted Answer

Jyotsna Talluri
Jyotsna Talluri on 5 Aug 2019
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!