You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
5 views (last 30 days)
Show older comments
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
Accepted Answer
Matt J
on 2 Feb 2023
Edited: Matt J
on 2 Feb 2023
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 Comments
Matt J
on 2 Feb 2023
Edited: Matt J
on 2 Feb 2023
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
on 2 Feb 2023
I dont to rescale the numbers, because they have meaning
What meaning? That's like saying centimeters have more meaning than kilometers.
Matt J
on 2 Feb 2023
Edited: Matt J
on 2 Feb 2023
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
on 2 Feb 2023
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
on 4 Feb 2023
Edited: M
on 4 Feb 2023
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
on 4 Feb 2023
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
on 4 Feb 2023
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
on 14 Jul 2024
Edited: M
on 14 Jul 2024
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
on 14 Jul 2024
Matt J
on 14 Jul 2024
Edited: Matt J
on 14 Jul 2024
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
on 15 Jul 2024
Edited: M
on 15 Jul 2024
@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
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)