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!