Quaternion roughly in XY: orient "up" as close to Z as poss.

   776   2   0
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
In vex, I have a quaternion (p@orient) where the N and up are close to the XY plane, but not exactly on it. I want to re-orient the quaternion, so that "up" points as closely into Z as possible, but without changing N. I.e. as if I grabbed the quaternion by the up vector and rotated it around the N so that "up" now points as close into Z as possible. How do I do this in vex? If both N and up were on the XY plane, I could just rotate "up" around the N 90 deg.
User Avatar
Member
4515 posts
Joined: Feb. 2012
Offline
Hi,

Here is one way:

vector4 q0 = p@orient;

float angle = radians ( 90 );
matrix3 m = ident ( );
rotate ( m, angle, @N );
vector4 q1 = quaternion ( m );

vector4 q2 = qmultiply ( q0, q1 );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
Great, thanks.
  • Quick Links