SPIRALIZE CURVE USING ROTATION MATRIX IN VEX
Updated: Mar 3, 2021
So last night I was in the process of developing a braid otl in houdini16.5 because I'm working on a character who in fact has braids. A hurdle that I had to overcome was how to make a curve spiral around its direction. To do this on a straight vertical curve is trivial. you would simply set the position to be cos(degree*@ptnum),@ptnum,sin(degree*@ptnum). This however doesn't translate to a bent curve at all. The coils will end up flattening in the x and z axes. I tried adding/multiplying the curve direction, but that was dumb. It still didn't account for rotation. The solution was undoubtedly a rotation matrix.
I had done a similar thing to create random rotation around branches for leaves. The only difference here was that it needed to spiral.
First, you would need to get the direction of the curve using a polyframe SOP.
The attribute it gives you by default it called tangentu. This is a vector attribute that is aimed at each point's previous point. You will be using that as the direction in a rotate function.
You will also need to get a vector pointing out away from the curve. To do this, do a cross product of the curve direction and the current normal.
The rotate function takes 3 inputs (matrix,rotation value in radians,axis). To create an open identity matrix you need to use the ident() function. The axis is the tangentu attribute. Then you would multiply this by the direction pointing away from the curve and add that value to position.
You should get something like this:
If that was weird or hard to follow, here's a HIP!