Quaternion and attribute create

   2477   2   2
User Avatar
Member
46 posts
Joined: March 2015
Offline
Hello,

I'm trying to create orient attribute within Attribute Create SOP with 4 components(quaternion) but seems like it doesn't work as expected.
When I change the angle(Fourth component) the object is rotating but it stops at about 180 degree no matter what value is in the box and rotation “slows down” when it's approaching 180 degree.

However if I use quaternion function with Attribute Wrangle it works exactly as expected.
@orient = quaternion(ch('angle'), myVec);

I wonder why Attribute Create works differently.

Thanks!

Attachments:
orientACSOP.hipnc (69.0 KB)

User Avatar
Member
1743 posts
Joined: March 2012
Offline
The 4th component of a quaternion isn't an angle. If you check the Geometry Spreadsheet with your Attribute Wrangle example, you can see that both component 1 and component 3 are changing. When going past 180 degrees, component 3 is negative.

Also, the angle of rotation will be the opposite of that in your Attribute Create, since 0,0,0,1is an identity transform, not 0,1,0,0, and since quaternions are scale-invariant, 0,1,0,10000000will be approximately equivalent to the identity transform 0,0,0,1.

Hopefully that at least clears up why there's an issue, though I'm not a good person to describe how quaternions actually do work. Sorry.
Edited by neil_math_comp - Aug. 28, 2018 11:33:09
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
7794 posts
Joined: Sept. 2011
Online
You can use attribute create sop with expressions if you do the math.

Attachments:
orient.zip (9.9 KB)

  • Quick Links