Surface and Line interaction point

47 ビュー (過去 30 日間)
Zarak kh
Zarak kh 2019 年 8 月 1 日
回答済み: Jyotsna Talluri 2019 年 8 月 5 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 8 月 1 日
Is this you are looking for?
pic54.png
Zarak kh
Zarak kh 2019 年 8 月 1 日
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.

サインインしてコメントする。

採用された回答

Jyotsna Talluri
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 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by