From: Natalie Sin Hwee on
Dear Mathworks,

I have two vectors in a 3D space.
By using:
theta(bb,cc) = atan2(norm(cross(v1,v2)) , dot(v1,v2) );
but it does not give me information on directionality of the angle Theta.

Looking at cart2sph/pol,

How can i find the theta/phi and r between two 3dimensional vectors?

Thank you
Natalie
From: Frédéric Bergeron on
Hey,

D'ont you could use the dot product?

u=[0 0 1]; v=[0 1 0];
theta=acosd(dot(u,v)/(norm(u)*norm(v)))

return 90 degrees, the angle between the two vectors in 3D...
Is that what you want?

Fred
From: Natalie Sin Hwee on
"Frédéric Bergeron" <frederic.bergeron(a)logiag.com> wrote in message <i3os8m$58o$1(a)fred.mathworks.com>...
> Hey,
>
> D'ont you could use the dot product?
>
> u=[0 0 1]; v=[0 1 0];
> theta=acosd(dot(u,v)/(norm(u)*norm(v)))
>
> return 90 degrees, the angle between the two vectors in 3D...
> Is that what you want?
>
> Fred

Hiya fred,

I'm tryna find two angles:

1) x-y plane

2) perpendicular to x-y plane

so i can map the location of the 2nd vector

Thanks ^^
Natalie
From: Matt J on
"Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3okop$9n9$1(a)fred.mathworks.com>...
> Dear Mathworks,
>
> I have two vectors in a 3D space.
> By using:
> theta(bb,cc) = atan2(norm(cross(v1,v2)) , dot(v1,v2) );
> but it does not give me information on directionality of the angle Theta.
======

v1 and v2 span a plane that cuts R^3 into two half-spaces. In order to set up a system of quadrants in this plane, and define which quadrant theta belongs to, you need some way of deciding which half-space is up and which half-space is down. This will probably require a 3rd vector residing in one of the half-spaces, marking it as up or down.



> Looking at cart2sph/pol,
>
> How can i find the theta/phi and r between two 3dimensional vectors?
=======

What's unclear? cart2sph returns these angles explicitly, so can't you get the separation by simple subtraction?
From: Natalie Sin Hwee on
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <i3p1v7$cps$1(a)fred.mathworks.com>...
> "Natalie Sin Hwee " <sin.ng09(a)imperial.ac.uk> wrote in message <i3okop$9n9$1(a)fred.mathworks.com>...
> > Dear Mathworks,
> >
> > I have two vectors in a 3D space.
> > By using:
> > theta(bb,cc) = atan2(norm(cross(v1,v2)) , dot(v1,v2) );
> > but it does not give me information on directionality of the angle Theta.
> ======
>
> v1 and v2 span a plane that cuts R^3 into two half-spaces. In order to set up a system of quadrants in this plane, and define which quadrant theta belongs to, you need some way of deciding which half-space is up and which half-space is down. This will probably require a 3rd vector residing in one of the half-spaces, marking it as up or down.
>
>
>
> > Looking at cart2sph/pol,
> >
> > How can i find the theta/phi and r between two 3dimensional vectors?
> =======
>
> What's unclear? cart2sph returns these angles explicitly, so can't you get the separation by simple subtraction?

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