Jump to content

Cartesian to Spherical coordinate system and back (VOP)


Recommended Posts

Hi, am I trying to create a tool in VOPs to rotate geometry (per point basis) on two angles. My approach was to switch from Cartesian coordinate system to spherical, manipulate angles and then go back to Cartesian.

I was using http://math.wikia.com/wiki/Spherical_coordinate_system formulas in VOPs to achieve that but I am pretty sure I messed up somewhere with trigonometric function signs. One angle manipulator works fine, but other distorts geometry and sifts point to opposite side of the object.

I have attached example.

If somebody did this before, please let me know where are my mistakes and what's the proper way to achieve what I am trying to do.

Thanks a lot

GTt06.VOPfixTest02.hip

Link to comment
Share on other sites

The results you are seeing are what I would expect when trying to rotate like you are. The nature of the spherical coordinate system doesn't really let you rotate the entire object about the angle theta since theta is an intermediary step in positioning a point.

Originally a point is moved from the origin up to R on the positive Z axis. The point is then rotated about the Y axis theta degrees and the finally rotated about the Z axis phi degrees so that it rests in it's final location. Changing phi is not a problem because the point is already at the proper "height". However, changing theta will start to distort your shape because each point as an initial angle theta already. As you try and rotate about theta and that initial angle combined with your rotational value approaches 180 your geometry approaches the (0,0,-Z) from all directions and then starts reversing due to the nature of sine/cosine. This is what causes your geometry to distort towards the bottom and then come back up and eventually end up completely opposite of the start when you rotate theta 180 degrees.

To get the result you are looking for you'll probably want to do some rotations about some axes. To actually rotate about that angle theta you'd rotate about the Y axes that many degrees, then rotate about Z for phi.

I think that all makes sense since it's been a while since I've done spherical coordinates.

Link to comment
Share on other sites

If all you want to do is express a rotation with two angles (as opposed to describing a position in terms of {r,phi,theta}), then I don't see why you need to bother with spherical coordinates at all.

Those two spherical angles (phi,theta) aren't "special" in any way -- they describe rotations about two orthogonal axes in 3D space (which is all you need to represent all possible directions in 3D... or, equivalently, all points on the surface of a sphere at some fixed distance 'r' from the origin).

Using the standard Houdini orientation and axis labels, the rotation that describes "azimuth" or "longitude" is identical to a rotation about Y, and the "zenith" or "polar" or "elevation" or "latitude" angle is a rotation in X (or Z, or any other vector on the X,Z plane -- there's an infinite number to choose from).

Here's a modification of your hip file which does just that -- rotates all points given two angles (like you would see in "spherical coordinates"). It uses a single Transform VOP.

GTt06.VOPfixTest02_mgm.hip

HTH.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...