Quarternions in chops

   5250   14   0
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
Hey friends

I am using an object chop to determine the bearing of two objects. I want to convert this data to quaternions in order to avoid gimbal lock.

It seems like it should be obvious, but I can't seem to figure out how to do this in chops.

First I tried to use the qlinear() function with the expression chop, but that resulted in my rotations being zeroed out.

Next I tired to import the data into vops and use the vector to quaternion vop, but I can't seem to figure out how to import the rotation channels into the vop chop.

Your wisdom please!
User Avatar
Member
7720 posts
Joined: July 2005
Offline
Where/how/what are you going to use the quaternions for? The best way to do it depends on how you want to use it.

In CHOPs, the euler rotation channels get marked together so that they get be treated as an orientation for better blending where available. So if you're strictly dealing with orientations in CHOPs, there shouldn't be a need to explicitly convert to quaternion.

The qlinear() expression just lets you do quaternion interpolation between the adjoining keyframes, on keyframe channels.

VEX in CHOPs processes one channel at a time, while you need access to all 3 euler rotation channels to generate a quaternion. So yeah, this won't work for sure.
User Avatar
Member
8554 posts
Joined: July 2007
Offline
It's not always automatic, maybe if you are using Object CHOP to bring rotation channels, but if you are bringing the channels by yourself using Fetch CHOP or creating them in CHOPs directly you need to mark rotation triplets as quaternion yourself using Attribute CHOP so some chops can treat such rotations as quaternions

http://www.sidefx.com/docs/houdini13.0/nodes/chop/attribute [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
Thanks for your input.

Clarification:

I am useing an object CHOP to get the bearing of two objects relative to one another.

I am exporting the bearing rotations to the rotation of an object COP. The current rotations are giving me erratic flipping at the projection poles. Thus I am trying to figure out how to convert those rotations to quaternions in order to avoid gimbal lock.

Thoughts?
User Avatar
Member
7720 posts
Joined: July 2005
Offline
Do you have a simple .hip file example?
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
I am trying to generate a dynamic silhouette.

Attachments:
generateSil.hipnc (227.8 KB)

User Avatar
Member
7720 posts
Joined: July 2005
Offline
I'm not sure I'd call that a simple .hip file.

The Object CHOP in that case is already using quaternions to rotate the reference's +Z axis such that points at the target object. However, there's no way to specify the up vector for that lookat so I think it's going to be really hard to control the roll of the object this way. So I don't think the flipping is because of gimbal lock, it's probably just that the roll for the orientation is changing. For using quaternions like this, the “roll” will be some “minimal effort” thing that will not be consistent unless you're doing it in very small rotation increments.

It might be better to use the objlookat [sidefx.com] expression to precisely control the upvector. The upvector in this case is well defined anyhow because you have a camera.

PS. It looks like you might be giving the Object CHOP a SOP path? In that case it might be using the identity transform instead of what you expect.
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
Thanks for your input Edward!

I am not really sure that I understand what you are suggesting.

When I turn off the Look At on the trace object, the object cop itself still produces flipping in the composite menu (when I am in line with the z axis).

Yet it still seems to happen even if I turn off the export flag on my export chop. (bypassing chops, and bearing, entirely)

I get the same sort of flipping either way.

I tried to use objlookat in on the rotation values of my object COP (bypassing chops entirely, and using the recipe in the link you provided). The the expression produced zeros and the flipping remains.

To clarify: the object CHOP is using a reference to parameters on the subnet that contains the “make silhouette” tools. Which in turn are connected an input object and my camera.

How do I attack this?
User Avatar
Member
7720 posts
Joined: July 2005
Offline
If you're just using object lookat's, are you specifying an up vector?
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
yes as part of the objlookat expression: (0,1,0)

This is being used in the object COP to control the rotation.
User Avatar
Member
7720 posts
Joined: July 2005
Offline
don't you want (0,1,0) in the camera's space?
User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
Thank you Edward for talking me through this. We are making progress.

I simplified the scene and implemented objlookat successfully, things are generally working more fluidly.

Unfortunately I am still getting some unwelcome rotation while looking down the x axis and moving the camera vertically.

Thoughts?

Attachments:
generateSil.hipnc (142.8 KB)

User Avatar
Member
7720 posts
Joined: July 2005
Offline
I don't think you need to do lookat's at all? For the Geometry COP, we want express lumpy's points in the space of the camera. eg. vorigin() expression. In this simple case, rotates are enough so I just used vrorigin() for just the rotates. Then once you trace this, you want to apply the inverse (ie. reverse the arguments to vorigin).

There seems to be strange scaling factor that the Geometry COP applies though so I had to had tweak that in the attached file.

Attachments:
generatesil_noLookAt.hipnc (131.9 KB)

User Avatar
Member
27 posts
Joined: Aug. 2013
Offline
Edward, this is amazing. Thank you!
User Avatar
Member
7720 posts
Joined: July 2005
Offline
Now that I think about it, the scaling factor kind of makes sense because the Geometry COP only does an orthographic projection while when I'm looking through the camera, it's doing a perspective projection.
  • Quick Links