Jump to content

How can I rotate a vector to another one, using VEX?


Masoud

Recommended Posts

Hi Masoud,

to blend orientations two orthogonal vectors are required for each point: one normal, one up. For this you could use the polyframe node or a cross() product.
maketransform() converts these vectors into a matrix that is to be turned into a quaternion().

matrix3 xform = maketransform(v@up, v@N);
vector4 orient = quaternion(xform);

slerp(), spherical linear interpolation, then blends between both orientations:

float blend = chf('blend');
vector4 orient_1 = point(0, 'orient', 1);
vector4 orient_2 = point(0, 'orient', 2);
p@orient = slerp(orient_1, orient_2, blend);

 

blend_orientations.hiplc

  • Thanks 1
Link to comment
Share on other sites

Hi Konstantin;
Thank you for the reply.

Actually, I want to rotate scattered points' Normal to another direction (i.e. MyVector) using a blend amount.

At first, I tried the lerp() function but instead of rotation, it blends them.

Then I tried:

float angle = chf("Angle");
vector4 rot = quaternion(radians(angle), v@myVector);
v@N = qrotate(rot, @N);

But it rotates the Normal around "My-Vector"!

 

Here is an image of what I need:
 

 

 

Rotate_Vector.hip

Roptate_Vector.jpg

Edited by Masoud
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...