Code covered by the BSD License  

Highlights from
plane intersection

5.0

5.0 | 1 rating Rate this file 15 Downloads (last 30 days) File Size: 1.94 KB File ID: #17618

plane intersection

by Nassim Khaled

 

20 Nov 2007 (Updated 02 Apr 2011)

It computes the intersection of two planes in space.

| Watch this File

File Information
Description

% Inputs:
% N1: normal vector to Plane 1
% A1: any point that belongs to Plane 1
% N2: normal vector to Plane 2
% A2: any point that belongs to Plane 2

%Outputs:
% P is a point that lies on the interection straight line.
% N is the direction vector of the straight line
% check is an integer (0:Plane 1 and Plane 2 are parallel'
% 1:Plane 1 and Plane 2 coincide
% 2:Plane 1 and Plane 2 intersect)

% Example:
% Determine the intersection of these two planes:
% 2x - 5y + 3z = 12 and 3x + 4y - 3z = 6
% The first plane is represented by the normal vector N1=[2 -5 3]
% and any arbitrary point that lies on the plane, ex: A1=[0 0 4]
% The second plane is represented by the normal vector N2=[3 4 -3]
% and any arbitrary point that lies on the plane, ex: A2=[0 0 -2]
% [P,N,check]=plane_intersect([2 -5 3],[0 0 4],[3 4 -3],[0 0 -2]);

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
21 Nov 2007 Jos x@y.z

This certainly looks like a decent function. It has ample help and internal comments, but the author has to fix some problems with that:

- add a % to empty lines in the help text so that "help plane_intersect" will display all the help, and not only the input requirements.

- create a H1 line (first line of help) which is used by lookfor.

- you could give a warning when parallel planes are entered and no 3rd output is asked for ..

Look at other ML functions how to set up a help section properly. If these problems are fixed I am happy to look at the actual algorithms.

22 Nov 2007 Thomas Pieper

Hello,

a possible general solution of this problem is as follows:

N=cross(N1,N2);
P=[N1;N2;N]\[dot(N1,A1);dot(N2,A2);0];

You don't have to handles 3 different cases. Checking for colinearity of the normal vectors is mandatory of course.

Best regards,

Thomas

28 Nov 2007 Nasser Farhat  
17 Feb 2011 phil

Instead of :

maxc=max(find(N==max(N)));

You should look for the max ABS value of the intersecting direction.

maxc=find(abs(N)==max(abs(N))));

You even mention this correctly in the comments:
"%first determine max abs coordinate of cross product"

Inserting these values will show the difference :
N1=[-0.0388 -0.10904 -0.99328];
A1=5*N1;
N2=[0 -1 0];
A2=[0 0 0]; %Plane at origin

Please login to add a comment or rating.
Updates
26 Nov 2007

Some useful comments from the file exchange community.

02 Apr 2011

I have read some new commments and responded by changing the code.

Tag Activity for this File
Tag Applied By Date/Time
plane intersection Nassim Khaled 22 Oct 2008 09:36:13
straight line Nassim Khaled 22 Oct 2008 09:36:13
3d Nassim Khaled 22 Oct 2008 09:36:13
space Nassim Khaled 22 Oct 2008 09:36:13
intersection Nassim Khaled 04 Apr 2011 13:31:01
intersect Nassim Khaled 04 Apr 2011 13:31:01
plane Nassim Khaled 04 Apr 2011 13:31:01
intersect Joerg 06 Sep 2011 03:54:16
plane intersection Sebastian 07 Jan 2012 04:32:15

Contact us at files@mathworks.com