From: Roger Stafford on
"Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3rcor$lvh$1(a)fred.mathworks.com>...
> If i have a line spanning between:
> a=[0.5, 0, 1];
> b=[0, 0.5, 0];
>
> how can i find the Theta and Phi in relation to the x-y Plane?
>
> Thank you
> Nataile
- - - - - - - - - -
I have carefully read each of your three postings in this thread, and I still don't understand what you are asking. You speak of a "Theta and Phi in relation to the x-y Plane". What precisely do you mean by that? Also you asked about an 'r' in the first post. I haven't the least idea what you mean by that.

Two vectors pointing from the 3D origin to two points will determine a plane. This plane and the x-y plane have a certain dihedral angle between them. Also the planes' line of intersection makes a certain angle as measured from the x-axis. Are these your phi and theta, respectively?

You will note that this is a very different question from determining the angle between the vectors. For example the dihedral angle can be found as the angle between the cross product of the vectors and the z-axis. If you took the cross product between this cross product and the z-axis you would have a vector along the line of intersection of the planes, and then you could find the angle between that and the x-axis. If you want specific formulas you need to be specific about what you are asking.

Roger Stafford
From: Natalie Sin Hwee on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <i3s4ak$ou$1(a)fred.mathworks.com>...
> "Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3rcor$lvh$1(a)fred.mathworks.com>...
> > If i have a line spanning between:
> > a=[0.5, 0, 1];
> > b=[0, 0.5, 0];
> >
> > how can i find the Theta and Phi in relation to the x-y Plane?
> >
> > Thank you
> > Nataile
> - - - - - - - - - -
> I have carefully read each of your three postings in this thread, and I still don't understand what you are asking. You speak of a "Theta and Phi in relation to the x-y Plane". What precisely do you mean by that? Also you asked about an 'r' in the first post. I haven't the least idea what you mean by that.
>
> Two vectors pointing from the 3D origin to two points will determine a plane. This plane and the x-y plane have a certain dihedral angle between them. Also the planes' line of intersection makes a certain angle as measured from the x-axis. Are these your phi and theta, respectively?
>
> You will note that this is a very different question from determining the angle between the vectors. For example the dihedral angle can be found as the angle between the cross product of the vectors and the z-axis. If you took the cross product between this cross product and the z-axis you would have a vector along the line of intersection of the planes, and then you could find the angle between that and the x-axis. If you want specific formulas you need to be specific about what you are asking.
>
> Roger Stafford

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
From: Roger Stafford on
"Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3u9la$rgu$1(a)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
From: Natalie Sin Hwee on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <i3v542$g20$1(a)fred.mathworks.com>...
> "Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3u9la$rgu$1(a)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

Dear Roger,

Thank you very much for your detailed help, i managed to interpret it into my code. Was wondering if i could obtain Theta from 0 to 2Pi (instead of -pi to +pi).


Thank you verymuch

Natalie
From: Roger Stafford on
"Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i40t2s$f0u$1(a)fred.mathworks.com>...
> Dear Roger,
> Thank you very much for your detailed help, i managed to interpret it into my code. Was wondering if i could obtain Theta from 0 to 2Pi (instead of -pi to +pi).
> Thank you verymuch
>
> Natalie
- - - - - - - - - - -
If you want to retain the theta angles from 0 to pi as they are at present and add 2*pi to those that are negative, you can change the last line to:

theta = mod(atan2(D(2),D(1)),2*pi);

Roger Stafford