Masoud Posted December 24, 2021 Share Posted December 24, 2021 Hello guys, Using VEX, how can I rotate a vector to another vector, by a blend value from zero to one (i.e 1=fully aligned, 0= not-aligned)? Thanks for helping. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted December 24, 2021 Share Posted December 24, 2021 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 1 Quote Link to comment Share on other sites More sharing options...
Masoud Posted December 25, 2021 Author Share Posted December 25, 2021 (edited) 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 Edited December 25, 2021 by Masoud Quote Link to comment Share on other sites More sharing options...
Librarian Posted December 25, 2021 Share Posted December 25, 2021 (edited) @Masoud Maybe it Helps! vector tips.hiplc Edited December 25, 2021 by Librarian 2 Quote Link to comment Share on other sites More sharing options...
Masoud Posted December 25, 2021 Author Share Posted December 25, 2021 Hi Tesan, Than you. Yes, it works fine: vector4 q1 = quaternion(@N); vector4 q2 = dihedral(v@N, v@targetVector); vector4 quat = slerp( q1, q2, chf("bias")); v@N = qrotate(quat, v@N); 1 Quote Link to comment Share on other sites More sharing options...
Librarian Posted December 25, 2021 Share Posted December 25, 2021 You are welcome @Masoud Check This 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.