math q: director vector to spherical coords

   2384   5   1
User Avatar
Member
178 posts
Joined: 1月 2013
Offline
Not strictly Houdini related, just a question from the mathematically challenged…

How can I convert a direction vector from cartesian to spherical coordinates?

I know the formula for a *position* (as well as the nodes topolar and frompolar) but not a vector… it's probably something simple that I'm overlooking…


Cheers,
Jon
User Avatar
Member
670 posts
Joined: 9月 2013
Offline
Isn't a position just a vector, as well?
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
178 posts
Joined: 1月 2013
Offline
I'm not sure…

Direction vectors must be treated differently when doing a space transformation, so I assumed that applied to this as well.
User Avatar
Member
258 posts
Joined: 7月 2006
Offline
wikipedia says

In mathematics, a spherical coordinate system is a coordinate system for three-dimensional space where the position of a point is specified by three numbers: the radial distance of that point from a fixed origin, its polar angle measured from a fixed zenith direction, and the azimuth angle of its orthogonal projection …

so you are missing two variables no, distance and azimuth angle
Head of CG @ MPC
CG Supervisor/ Sr. FX TD /
https://gumroad.com/timvfx [gumroad.com]
www.timucinozger.com
User Avatar
Member
7771 posts
Joined: 9月 2011
Offline
A direction vector is also a position on the unit sphere. You can use topolar for a direction vector, and it will return phi and theta, with r being the length of the vector (one if normalized).
User Avatar
Member
178 posts
Joined: 1月 2013
Offline
Thanks, easier than I thought! And now makes more sense.
  • Quick Links