# Finding Polar & Azimuthal Angles of 3D Vector

• susantha
In summary, Susanthawelcome to pf! and drop a perpendicular from (x,y,z) to the x,y plane … that gives you tanθ, then φ wil be the usual planar polar coordinate :wink:You can, of course, calculate the vector from A to B just by subtracting coordinates. You can then calculate the unit vector by dividing each component by the length of the vector. And the components of that unit vector are the "direction cosines". That is, if the unit vector is a\vec{i}+ b\vec{j}+ c\vec{k} and the angle the vector makes

#### susantha

Hi,
Can anybody help me to find the polar angle and the azimuthal angle of a given 3D vector? Say we know the ordinates of the two point A(x1,y1,z1) and B(x2,y2,z2). So the question is find angles (Theta and Phi) of the vector AB. Any suggestion would be really appreciated.

Thanks.
Susantha

welcome to pf!

hi susantha! welcome to pf!

(have a theta: θ and a phi: φ and try using the X2 icon just above the Reply box )

drop a perpendicular from (x,y,z) to the x,y plane … that gives you tanθ, then φ wil be the usual planar polar coordinate

You can, of course, calculate the vector from A to B just by subtracting coordinates. You can then calculate the unit vector by dividing each component by the length of the vector.

And the components of that unit vector are the "direction cosines". That is, if the unit vector is $a\vec{i}+ b\vec{j}+ c\vec{k}$ and the angle the vector makes with the x-axis is $\theta$, the angle the vector makes with the y-axis is $\phi$, and the angle the vector makes with the z-axis is $\psi$, then

$$a= cos(\theta)$$,
$$b= cos(\phi)$$,
and
$$c= cos(\psi)$$

Of course, those angles are not independent: $cos^2(\theta)+ cos^2(\phi)+ cos^2(\psi)= 1$ so it is sufficient to know two.

If I understand you correctly, the "polar angle" is $\theta$ and the "azimuthal angle" is $\psi$.

Thank you for your valuable comments. Now I guess I have the algorithm to find two angles (teta and phi) of a given 3d vector. Here is the algorithm:

// First find the vector AB. (vector AB= vector B - vector A). B=(x1,y1,z1) and A=(x2,y2,z2)
// vector AB =(del_x, del_y, del_z);
del_x = x1-x2;
del_y = y1-y2;
del_z = z1-z2;
// Then we can find the magnitude of the vector AB,
r=sqrt (del_x^2 + del_y^2 +del_z^2);
s = sqrt ( del_x^2 + del_y^2 );
teta = arccos(del_z / r); // teta is the polar angle

//to find the azimuth angle,
if (del_x > 0)
phi= arcsin( del_y / s);
else
phi=pi - arcsin( del_y / s);

if (del_x > 0 && del_y <0 )
phi= pi - phi;

The last if condition is to make sure the phi has positive values between zero and 2*pi.

Susantha

Hello Susantha,

To find the polar angle and azimuthal angle of a 3D vector, you can use the following formulas:

Polar angle (Theta) = arccos(z/r)

Azimuthal angle (Phi) = arctan(y/x)

Where r is the magnitude of the vector (AB), which can be calculated using the Pythagorean theorem:
r = √((x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2)

I hope this helps. Let me know if you have any further questions or need clarification. Good luck with your calculations!

Best,

## 1. How do you find the polar angle of a 3D vector?

The polar angle of a 3D vector can be found by taking the inverse cosine of the z-component of the vector divided by the magnitude of the vector.

## 2. What is the formula for calculating the azimuthal angle of a 3D vector?

The formula for calculating the azimuthal angle of a 3D vector is arctan(y/x), where x and y are the x and y components of the vector, respectively.

## 3. Can the polar and azimuthal angles of a 3D vector be negative?

Yes, the polar and azimuthal angles of a 3D vector can be negative. This indicates that the vector is pointing in the opposite direction from the positive axis.

## 4. How are the polar and azimuthal angles of a 3D vector related to its components?

The polar angle is related to the z-component of the vector, while the azimuthal angle is related to the x and y components. The polar angle determines the vertical angle from the positive z-axis, while the azimuthal angle determines the horizontal angle from the positive x-axis.

## 5. Why is it important to know the polar and azimuthal angles of a 3D vector?

Knowing the polar and azimuthal angles of a 3D vector is important for understanding the direction and orientation of the vector in space. It is also useful for many applications in mathematics, physics, and engineering, such as calculating forces, determining the direction of motion, and analyzing rotational motion.