How to find Intersection point of plane and vector/line in 3d
Ältere Kommentare anzeigen
Hello! Could you please help me why my fucntion does not calculate intersection point I. It gaves me my initial X0, Y0, Z0 coordinate
I used this example
[I ] = planeLocation6(1.5, 3.3371, 0.1820)
function [ I ] = planeLocation6(XBar, YBar, ZBar)
X0 = 1.5;
Y0 = 1.5;
Z0 = 3.0;
Theta0 = 30;
planes(:,:,1) = [0 3 3; 0 0 3; 0 3 0; 0 0 0; 0 0 0];
planes(:,:,2) = [0 0 3; 3 0 3; 0 0 0; 3 0 0; 0 0 0];
planes(:,:,3) = [3 0 3; 3 3 3; 3 0 0; 3 3 0; 3 0 0];
planes(:,:,4) = [3 3 3; 0 3 3; 3 3 0; 0 3 0; 0 3 3];
planes(:,:,5) = [0 3 0; 3 3 0; 0 0 0; 3 0 0; 0 0 0];
planes(:,:,6) = [0 3 3; 3 3 3; 0 0 3; 3 0 3; 0 0 3];
location_plane = 6;
for j=1:6
j==location_plane
plane = planes(:,:,j);
p0 = plane(1,:);
p1 = plane(2,:);
p2 = plane(3,:);
p3 = plane(4,:);
V0 = plane(5,:);
Ri = [X0 Y0 Z0];
Rr = [XBar YBar ZBar];
u = Rr-Ri;
w=Ri-V0;
A = p0-p2;
B = p0-p3;
n=cross(A,B); % normal vector of the Plane
u = Rr-Ri;
w=Ri-V0;
D=dot(n,u);
N=-dot(n,w);
sI = N / D;
I = Ri+ sI.*u;
disp(I);
end
Thank you in advance, BR Aknur
3 Kommentare
Rik
am 23 Feb. 2023
Your code doesn't actually call the function you linked. Is there a reason why you don't want to use it?
Rik
am 28 Feb. 2023
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
Aknur
am 2 Mai 2023
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Multidimensional Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!