0

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

Gary Tsui
  • 195

1 Answers1

1

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.

Bombyx mori
  • 19,638
  • 6
  • 52
  • 112
  • thanks, say, W.R.T to x-axis (same thing as in the 2D case), sorry, im a bit confused, in 2D case, i 'll get one value for the angle (deg/rad). Does that mean, using your answer, i would get 3 values? Thanks very much again. – Gary Tsui Nov 16 '13 at 09:00
  • Yes. You need 3 angles to locate the location of the vector, though in fact 2 is enough. – Bombyx mori Nov 16 '13 at 09:21
  • Interesting, how come in my 2D case, i only need one angle (as shown in the question)? Thanks once again. – Gary Tsui Nov 16 '13 at 09:41
  • @GaryTsui: I shall leave you to think about it. – Bombyx mori Nov 16 '13 at 09:47
  • hmmmm, could it be Gx/Gx = 1? Anyway in your solution, i think Beta / r should be y / r? and gamma / r should be z /r ? and r should be that certain axis ? say x, cos (alpha) = Gx / Gx, cos(beta) = Gy/Gx, and cos(gamma) = Gz / Gx ? That's why you stated in the comments that 2 is enough? If these are correct, i'll accept your answer. Thanks. – Gary Tsui Nov 16 '13 at 09:51
  • @GaryTsui: There is a typo as you noticed. But I mean 2 is enough because of standard spherical coordinates. For the 2D case, if you know one angle, the other one is just the complement. – Bombyx mori Nov 16 '13 at 10:42
  • may i know why it is cos instead of atan (as seen in 2D) case? And i am still a bit confused, can your solution be applied to Gradients ? The reason why i am asking because the mag and ang should be able to be derived from the gradients. My apologies i am still confused. Thanks. – Gary Tsui Nov 16 '13 at 10:59
  • @GaryTsui: This is not related to Gradients, but any vector in general. You can use $\arctan$ for the 2D case, but in general it is not properly defined. So $\cos$ or $\sin$ is easier. – Bombyx mori Nov 16 '13 at 11:54
  • Thanks, but i would like to have a way specific to Gradients. – Gary Tsui Nov 18 '13 at 05:48