Surface and Line interaction point

41 vues (au cours des 30 derniers jours)
Zarak kh
Zarak kh le 1 Août 2019
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 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 1 Août 2019
Is this you are looking for?
pic54.png
Zarak kh
Zarak kh le 1 Août 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.

Connectez-vous pour commenter.

Réponse acceptée

Jyotsna Talluri
Jyotsna Talluri le 5 Août 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

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by