How I can find intersection point of direction vector and one of the given plane of 3d cube
조회 수: 16 (최근 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
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
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
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
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
2023년 2월 20일
Have reviewed this solution: https://www.mathworks.com/matlabcentral/answers/93623-how-do-i-plot-the-line-of-intersection-between-two-surfaces
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!