Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Finding 3D Angle
Date: Wed, 11 Aug 2010 21:36:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <i3v542$g20$1@fred.mathworks.com>
References: <i3okop$9n9$1@fred.mathworks.com> <i3p1v7$cps$1@fred.mathworks.com> <i3rcor$lvh$1@fred.mathworks.com> <i3s4ak$ou$1@fred.mathworks.com> <i3u9la$rgu$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1281562562 16448 172.30.248.38 (11 Aug 2010 21:36:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Aug 2010 21:36:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:661215

"Natalie Sin Hwee " <sin.ng09@imperial.ac.uk> wrote in message <i3u9la$rgu$1@fred.mathworks.com>...
> Hi Roger,
> 
> Sorry about that i will try to explain myself again. In a 3D space( x and y plane is e.g. the flat table on the base, and Z direction points upwards perpendicular to the 'table'/base)
> 
> I have two vectors A and B.  A is pointing towards B. 
> I want to find the 
> 1) Dihedral angle between Plane AB and Plane XY - and i think its called Phi.
> 2)X axis to Plane AB- and i think it is called Theta. 
> 
> The notations are similar to the diagram found for help Sph2cart 
> 
> I hope i have explained myself better.
> Thank you
> 
> Natalie
- - - - - - - -
  Here's my try at getting your phi and theta for vectors A and B.  Assume A and B are column vectors.

 C = cross(A,B); % Vector orthogonal to plane of A and B
 Z = [0;0;1]; % z-axis, normal to xy plane
 D = cross(Z,C); % D points along the planes' intersection line
 phi = atan2(norm(D),dot(Z,C)); % The angle between the planes
 theta = atan2(D(2),D(1)); % Angle counterclockwise from x-axis to D.

  You will notice that this answer depends on which order you take for vectors A and B.  I base it on your statement "A is pointing towards B".  Vector C is normal to the plane of vectors A and B.  Vector Z is the z-axis vector and is normal to the xy plane.  The dihedral angle phi between the plane of AB and the xy plane is the angle between their normals C and Z, resp.  As computed here it will range from 0 to pi.  Vector D lies in the xy plane and points along the intersection between the two planes.  The angle theta is the angle measured counterclockwise in the xy plane from the x-axis to vector D, and as computed here it ranges from -pi to +pi.

  I hope these are the quantities you wanted.  None of your four posts gives a non-ambiguous description of that.  For example when you say "X axis to Plane AB", that can be interpreted in more than one way.  I have interpreted it as above.  When you say "Dihedral angle between Plane AB and Plane XY" you don't make clear which of two possible angles that might be, one the supplement of the other.  As you see above I have made it depend on which way C is pointing, upwards or downwards, but that depends on whether A is considered first or B first.  The value for theta depends on which way along the line of plane intersection D points.  If you reverse D, that changes theta by pi.

  I hope this last discussion of the ambiguities involved would enable you to make the necessary corrections yourself if my interpretation is not in line with yours.

Roger Stafford