How to find out the cordinates of the intersection point of a line and a surface?
3 次查看(过去 30 天)
显示 更早的评论
Hello
I need to find out weather a line that connect to points in a 3D situation have an intersection with a surface or not, and also report the intersection point for further steps.
Imagine I have two points A and B ( which needs to be connected) a surface z.
A : x= 0.5 y=-0.5 z=-1
B : x=-0.7 y=1 z=1.5
and the surface z is:
[x, y] = meshgrid(linspace(-1, 1));
z = y.^2 + 2*x;
"The above data are just as an example"
Thanks alot for any help on my question
0 个评论
采纳的回答
Matt J
2019-7-30
编辑:Matt J
2019-7-30
Plug the equation for the line into the equation for the surface and use fzero to find the root. This root will give the location of the intersection.
L=@(t) A+(B-A)*t; %line equation
S= @(xyz) xyz(3)-xyz(1).^2 -xyz(2).^2; %surface equation
t_intersection = fzero(@(t) S(L(t)) ,t0 )
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!