How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
5 次查看(过去 30 天)
显示 更早的评论
M
2023-2-2
How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
The following points contain the following points:
The first plane:
P1 = 177668442.453315 -102576923.076923 0
P2 = -102576923.076923 177668442.453315 -102576923.076923
P3= 0 -102576923.076923 88834221.2266576
The secod Plane:
P1= 152763459.308716 -102576923.076923 0
P2= -102576923.076923 183536536.231793 -102576923.076923
P3= 0 -102576923.076923 91768268.1158967
采纳的回答
Matt J
2023-2-2
编辑:Matt J
2023-2-2
A=null([[P11;P21;P31],ones(3,1)]); %plane 1
B=null([[P12;P22;P32],ones(3,1)]); %plane 2
L=A*B.' - B*A.'; %line of intersection
However, for this to work well, you must re-express your P data in larger units, as Torsten suggests.
25 个评论
Matt J
2023-2-2
编辑:Matt J
2023-2-2
P1=[177668442.453315 -102576923.076923 0
-102576923.076923 177668442.453315 -102576923.076923
0 -102576923.076923 88834221.2266576]/100000000;
P2=[152763459.308716 -102576923.076923 0
-102576923.076923 183536536.231793 -102576923.076923
0 -102576923.076923 91768268.1158967]/100000000 *[0 1 0;1 0 0; 0 0 1];
A=null([P1,ones(3,1)]); %plane 1
B=null([P2,ones(3,1)]); %plane 2
L=A*B.' - B*A.'; %line of intersection
N=null(L);
t=linspace(-.1,.1);
xyz=N(:,1) + N(:,2)*t;
xyz=num2cell(xyz(1:3,:)./xyz(4,:),2);
line(xyz{:}); grid on; view(3)
plotPlane(A)
plotPlane(B)
axis([-1,1,-1,1,-1,1]*200)
function plotPlane(H)
hold on;
fimplicit3(@(x,y,z)H(1)*x+H(2)*y+H(3)*z+H(4),'EdgeColor','none','FaceAlpha',0.3,'FaceColor','r')
hold off
end
Matt J
2023-2-2
I dont to rescale the numbers, because they have meaning
What meaning? That's like saying centimeters have more meaning than kilometers.
Matt J
2023-2-2
编辑:Matt J
2023-2-2
In any case, it still works with the P data as originally scaled:
P1 =[177668442.453315 ,-102576923.076923, 0];
P2 =[ -102576923.076923 ,177668442.453315 ,-102576923.076923];
P3= [0, -102576923.076923, 88834221.2266576];
P11= [152763459.308716 , -102576923.076923, 0];
P22=[ -102576923.076923, 183536536.231793 , -102576923.076923];
P33= [0, -102576923.076923, 91768268.1158967];
hold on
A=null([[P1;P2;P3],ones(3,1)]); %plane 1
B=null([[P11;P22;P33],ones(3,1)]); %plane 2
L=A*B.' - B*A.'; %line of intersection
N=null(L);
t=linspace(-0.1,0.1);
xyz=N(:,1) + N(:,2)*t;
xyz=num2cell(xyz(1:3,:)./xyz(4,:),2);
plot3(xyz{:}); grid on
line(xyz{:}); grid on; view(3)
plotPlane(A)
plotPlane(B)
axis([-1,1,-1,1,-1,1]*200)
function plotPlane(H)
hold on;
fimplicit3(@(x,y,z)H(1)*x+H(2)*y+H(3)*z+H(4),'EdgeColor','none','FaceAlpha',0.3,'FaceColor','r')
hold off
end
Matt J
2023-2-2
line() takes the same kind of arguments as patch()
Example: line(x,y,'Color','red','LineWidth',3) creates a red line that is 3 points wide.
M
2023-2-4
编辑:M
2023-2-4
For example they became 4 instead of 3 , I edited the code as the follwoing, and I got the intersected line
P4 = [0 0 -136769230.769231 126358292.985005]
P44= [0 0 -136769230.769231 127179926.292009]
A=null([[P1;P2;P3;P4],ones(4,1)]); %plane 1
B=null([[P11;P22;P44],ones(4,1)]); %plane 2
L=A*B.' - B*A.'; %line of intersection
But I faced errors in ploting part and I didnt know how to edit 'xyz' ?
could you please tell me what is the 'xyz' and based on what I should edit it ?
N=null(L);
t=linspace(-0.1,0.1);
xyz=N(:,1) + N(:,2)*t;
xyz=num2cell(xyz(1:3,:)./xyz(4,:),2);
plot3(xyz{:}); grid on
line(xyz{:}); grid on; view(3)
plotPlane(A)
plotPlane(B)
axis([-1,1,-1,1,-1,1]*200)
Matt J
2023-2-4
But I faced errors in ploting part and I didnt know how to edit 'xyz' ?
I don't think so. The code you posted doesn't even run to the creation of A and B. It also doesn't really make sense that you would be adding a 4th point. Four points are not generally coplanar.
P1 =[177668442.453315 ,-102576923.076923, 0];
P2 =[ -102576923.076923 ,177668442.453315 ,-102576923.076923];
P3= [0, -102576923.076923, 88834221.2266576];
P11= [152763459.308716 , -102576923.076923, 0];
P22=[ -102576923.076923, 183536536.231793 , -102576923.076923];
P33= [0, -102576923.076923, 91768268.1158967];
P4 = [0 0 -136769230.769231 126358292.985005]
P4 = 1×4
1.0e+08 *
0 0 -1.3677 1.2636
P44= [0 0 -136769230.769231 127179926.292009]
P44 = 1×4
1.0e+08 *
0 0 -1.3677 1.2718
A=null([[P1;P2;P3,P4],ones(4,1)]) %plane 1
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Dimensions of arrays being concatenated are not consistent.
B=null([[P11;P22;P44],ones(4,1)]) %plane 2
M
2023-2-4
P1 =[252716585.970010 -136769230.769231 0 0];
P2 =[ -136769230.769231 252716585.970010 -136769230.769231 0];
P3= [0 -136769230.769231 252716585.970010 -136769230.769231];
P11= [233844467.968633 -136769230.769231 0 0];
P22=[ -136769230.769231 254359852.584018 -136769230.769231 0];
P33= [0 -136769230.769231 254359852.584018 -136769230.769231];
P4 = [0 0 -136769230.769231 126358292.985005];
P44= [0 0 -136769230.769231 127179926.292009];
A=null([[P1;P2;P3;P4],ones(4,1)]) %plane 1
A = 5×1
0.2420
0.4472
0.5843
0.6325
0.0000
B=null([[P11;P22;P33;P44],ones(4,1)]) %plane 2
B = 5×1
0.2657
0.4542
0.5791
0.6227
0.0000
L=A*B.' - B*A.' %line of intersection
L = 5×5
0 -0.0089 -0.0151 -0.0173 -0.0000
0.0089 0 -0.0064 -0.0088 -0.0000
0.0151 0.0064 0 -0.0024 -0.0000
0.0173 0.0088 0.0024 0 -0.0000
0.0000 0.0000 0.0000 0.0000 0
M
2024-7-14
编辑:M
2024-7-14
Hi @Matt J, could you please elaborate to me why did you scale P1 and P2 as the following? why did you transform P2 only??
Also, Why do the planes have six vertices in the plot?
Thanks
P1=[177668442.453315 -102576923.076923 0
-102576923.076923 177668442.453315 -102576923.076923
0 -102576923.076923 88834221.2266576]/100000000;
P2=[152763459.308716 -102576923.076923 0
-102576923.076923 183536536.231793 -102576923.076923
0 -102576923.076923 91768268.1158967]/100000000 *[0 1 0;1 0 0; 0 0 1];
M
2024-7-14
Matt J
2024-7-14
编辑:Matt J
2024-7-14
could you please elaborate to me why did you scale P1 and P2 as the following?
Because in these lines, the ones(3,1) become vanishingly small compared to the Pij data if you don't scale them.
A=null([[P11;P21;P31],ones(3,1)]); %plane 1
B=null([[P12;P22;P32],ones(3,1)]); %plane 2
why did you transform P2 only??
I think I just didn't like the P2 that you gave. I wanted a different P2 data set for the example.
Also, Why do the planes have six vertices in the plot?
Becase the plot box has 12 edges, but the planes only intersect 6 of them.
M
2024-7-15
编辑:M
2024-7-15
@Matt J Thanks for your reply.
Becase the plot box has 12 edges, but the planes only intersect 6 of them.
Regarding this, Is there a way to control the vertices? for example to have only 4 vertices in the plot? or that will affect the meaning or so ? I need the plots only for visualization purposes in my research, having 6 vertices looks weird
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)