![pic54.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/232260/pic54.png)
Surface and Line interaction point
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Zarak kh
le 1 Août 2019
Réponse apportée : Jyotsna Talluri
le 5 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
Réponse acceptée
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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!