How I can find intersection point of direction vector and one of the given plane of 3d cube

21 Ansichten (letzte 30 Tage)
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 Kommentare
Rik
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.
Matt J
Matt J am 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);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 20 Feb. 2023
Bearbeitet: Matt J am 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 Kommentare
Aknur
Aknur am 20 Feb. 2023
Hello, Dear @Matt J thank you for your time and help. Wow your code looks great. Thank you so much. I am trying to understand and apply it. 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 have used 5 'corner' - they are 4 corners and one point which is lying on that each plane. I tried to find intersection using dot function using normal of each plane and point which is lying on the plane.
Matt J
Matt J am 20 Feb. 2023
Bearbeitet: Matt J am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 20 Feb. 2023
  1 Kommentar
Aknur
Aknur am 20 Feb. 2023
Bearbeitet: Aknur am 20 Feb. 2023
Dear, @Sulaymon Eshkabilov thank you for your response and for your time. I am a little bit dot understand exactly how to work in Matlab, and still new in it
I am checking your suggestion. I could not understand. If I am undestand right is not exactly what I need.
I have tried another one example/solution
https://www.mathworks.com/matlabcentral/fileexchange/103835-plane-and-lie-intersection
But in this example they consider only two planes. In my case I need to check all planes. Because then I will rotate and continue to do the same steps for the next vectors, etc

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Historical Contests finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by