# vector rotation in vex (vop)

## Recommended Posts

Hi,

I would like to ask, that how could I rotate a vector around another vector with VOPs? I want to rotate the up vectors around the normals of points in a VOP SOP. My first attempt was to construct a matrix with the lookat node, then rotate it around N with 'rotate' and then convert it back to a vector (last three floats of the 3x3 matrix). This network doesn't work perfectly and it seems to be a bit complicated comparing to the problem. My understanding of matrices, quaternions and the related part of vex is very shallow (as you probably already found out), but I would like to know and understand more about them, so this is why I'm trying to do it this way and not in SOPs.

bmt

##### Share on other sites
anim    589

use rotate VOP to create matrix

axis would be normalised N

angle would be the angle you want (in radians)

plug the matrix to orient VOP "xform" input

plug the up vector to orient VOP "from" input

output of orient VOP is your rotated up vector around N by angle

or you can simply multiply up vector with that matrix, it will rotate it as well

##### Share on other sites
sam.h    10

like so ... you are too fast anim (or google reader is too slow...)

rotate_vector.hip

Edited by sam.h

##### Share on other sites

thanks guys for the quick reply!

this makes a lot more sense . the only issue was that I wanted to rotate the ups around the Ns and not the other way around, but the principle is correct, so a quick rewire in your example did the thing.

thanks again!

bmt

##### Share on other sites

hello I was wondering if any of you could help me with a similar problem I'm trying to work out in vops

I originally posted it in general Houdini questions and although it is to do with sprites I think needs the insight of a modeler.

http://forums.odforce.net/index.php?showtopic=9315

I've been scratching my head with it for a few weeks now so any new insights would be well appreciated

##### Share on other sites
On 7/16/2009 at 9:15 PM, sam.h said:

like so ... you are too fast anim (or google reader is too slow...)

Wow thanks so much! To be completely honest I don't understand how matrices works nor how your setup works but it solved my problem!

##### Share on other sites

You can do it without matrices by using a quaternion and a quaternion rotate like so :
quaternions are just vector 4 float (axis X, axis Y , axis Z, angle in radians)

qrotate_vector.hip