How I can find intersection point of direction vector and one of the given plane of 3d cube
16 views (last 30 days)
Show older comments
Hello everyone! Kindly ask help. How I can find intersection point of direction vector and given planes of cube. I have X0, Y0, Z0 and X, Y, Z and planes. (X0 =1.5; Y0 =1.5; Z0 =3.0; X = 1.5; Y = 3.0;Z = 0.699097;)
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;
Here is my function. I want to define coordinates of intersection point I1, I2, I3 and p is with which location plane intersect. Much appreciate any help
function [p, I1, I2, I3 ] = planeLocation5(X, Y, Z)
X = 1.5;
Y = 3.0;
Z = 0.699097;
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 jj=1:6
plane = planes(:,:,j);
2 Comments
Rik
on 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.
Matt J
on 28 Feb 2023
Back-up copy of original question:
Hello everyone! Kindly ask help. How I can find intersection point of direction vector and given planes of cube. I have X0, Y0, Z0 and X, Y, Z and planes. (X0 =1.5; Y0 =1.5; Z0 =3.0; X = 1.5; Y = 3.0;Z = 0.699097;)
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;
Here is my function. I want to define coordinates of intersection point I1, I2, I3 and p is with which location plane intersect. Much appreciate any help
function [p, I1, I2, I3 ] = planeLocation5(X, Y, Z)
X = 1.5;
Y = 3.0;
Z = 0.699097;
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 jj=1:6
plane = planes(:,:,j);
Accepted Answer
Matt J
on 20 Feb 2023
Edited: Matt J
on 20 Feb 2023
Fairly eay to do to do with this FEX download,
However, in your list of the 6 cube faces, you've given each face 5 corners instead of 4, which doesn't seem right. So, I didn't use that description below.
X0 =1.5; Y0 =1.5; Z0 =3.0; X = 1.5; Y = 3.0;Z = 0.699097;
[p, I ] = planeLocation([X,Y,Z],[X0,Y0,Z0])
p =
5
6
I =
1.5000 3.0000 0.6991
1.5000 1.5000 3.0000
function [p, I ] = planeLocation(XYZ,XYZ0)
[A,b]=addBounds([],[],[],[],[0,0,0],[3,3,3]); % equations for cube faces
[~,~,Aeq,beq]=vert2lcon([XYZ;XYZ0]); %equations for line
S=intersectionHull('lcon',A,b,'lcon',[],[],Aeq,beq); %compute intersections
if isempty(S.vert)
warning 'No intersections'
p=[]; I=[]; return
end
I=S.vert; %intersection points
%%Compute which faces intersection points belong to
Ab=[A,b];
ab=[S.lcon{1:2}];
[~,p]=ismembertol(ab,Ab,1e-8,'ByRows',1,'DataScale',1);
end
2 Comments
Matt J
on 20 Feb 2023
Edited: Matt J
on 20 Feb 2023
I got this error "Out of memory. The likely cause is an infinite recursion within the program." Kindly ask if you know how I can fix it
I don't know what you might have done to produce that. When I run with the input data you supplied us, I get the output shown above.
More Answers (1)
Sulaymon Eshkabilov
on 20 Feb 2023
Have reviewed this solution: https://www.mathworks.com/matlabcentral/answers/93623-how-do-i-plot-the-line-of-intersection-between-two-surfaces
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!