Make normals orthogonal to custom vector

   1261   2   2
User Avatar
Member
69 posts
Joined: Nov. 2021
Offline
Hi there,

I'm trying to realign my normal vectors on the left sphere to look like the normals on the right sphere using the red vector which is just {0, 1, 0} in this example. For this example I just set N.y to 0 and normalized N but I need this to be interactive so the yellow normals are always orthogonal to the red vector.

I thought it should be fairly easy but I just can't figure it out right now.
I hope you can help me out with this!
Edited by eaniix - Oct. 16, 2024 14:42:22

Attachments:
vector.jpg (185.5 KB)

User Avatar
Member
5205 posts
Joined: Feb. 2012
Offline
Hi,

You mean like this?

@v = normalize ( set ( @N.x, 0, @N.z ) );

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
User Avatar
Member
69 posts
Joined: Nov. 2021
Offline
I figured it out!

I used the cross product between both vectors and then rotated that 90 degrees around the red vector.

Here's the code I used:

vector dir = normalize(chv('direction'));
v@N = cross(v@N, dir);

vector4 rot = quaternion(radians(90), dir);
v@N = qrotate(rot, v@N);
v@N = normalize(v@N);
  • Quick Links