Code covered by the BSD License  

Highlights from
plane intersection

5.0

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

plane intersection

by

 

20 Nov 2007 (Updated )

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   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
02 May 2013 IME Mecha engg

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]);

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

28 Nov 2007 Nasser Farhat  
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

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.

Updates
02 Apr 2011

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

Contact us