필터 지우기
필터 지우기

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

조회 수: 12 (최근 30일)
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
Rik
Rik 2023년 2월 28일
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 2023년 2월 28일
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);

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2023년 2월 20일
편집: Matt J 2023년 2월 20일
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
Aknur
Aknur 2023년 2월 20일
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 2023년 2월 20일
편집: Matt J 2023년 2월 20일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 20일
  댓글 수: 1
Aknur
Aknur 2023년 2월 20일
편집: Aknur 2023년 2월 20일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by