How do you get 3D gradient direction and magnitude?

1.9k Views Asked by At

I know that we can get the magnitude and direction from 2D gradient ?

  1) mag(Gx,Gy)  = sqrt ( Gx^2 + Gy^2 )
  2) angle(Gx, Gy) = tan^-1 (Gy/Gx)

What about in 3D?

  1) mag(Gx,Gy,Gz)  = sqrt ( Gx^2 + Gy^2 + Gz^2 )
  2) angle(Gx,Gy,Gz) = **???**

I seriously need your help.

Many, many thanks,

Gary

1

There are 1 best solutions below

9
On

I think you mean you want to calculate the length of a vector and its angle related to a certain axis, like $x$-axis. I think the tool you use is $\cos[\alpha]=\frac{x}{r},\cos[\beta]=\frac{y}{r},\cos[\gamma]=\frac{z}{r}$, etc. This carries to the general $n$-variable case without much difficulty.