Need help for rolling a line into a spiral

   7091   10   1
User Avatar
Member
1 posts
Joined: March 2020
Offline
Hi, I'm new to Houdini and I am struggling with one task which I thought will be simple.

I have a line with 50 points (I tried with a line, curve and just copied points) which I am trying to bend into a spiral (I tried using bend, but it makes perfect circles, and I want a spiral, I also tried to use attribute wrangle to set rotation on points manually, but I was not able to set correct pivots for each point, they all have the same pivot).

What is the approach here in general if I want to roll something into a spiral.

The thing that I am trying to do is to roll rice mat into a sushi roll.
User Avatar
Member
676 posts
Joined: Feb. 2017
Offline
Hey constantgenerator,

the bend sop is one way to do it. you have to adjust the capture direction to make it spiral.
take a look.

Cheers
CYTE

Attachments:
roll.hiplc (109.6 KB)

User Avatar
Member
833 posts
Joined: Jan. 2018
Offline
SideFX Labs Spiral?

https://www.sidefx.com/products/sidefx-labs/sidefx-labs-tools/ [www.sidefx.com]


I made a tutorial on SideFX Labs excellent set of tools, including Spiral. You can watch it here:

>>Kays
For my Houdini tutorials and more visit:
https://www.youtube.com/c/RightBrainedTutorials [www.youtube.com]
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
point SOP, dropdown preset
User Avatar
Member
340 posts
Joined: June 2017
Offline
It is interesting to see different ways to do this. I would use an attribute expression node to make this spiral. If you allow editing of contents on the lab spiral solution, you can see how they did it. But here is a three node solution (with a couple extra nodes to create a sushi wrap.

Update, I realize this is probably what was meant by point sop.
Edited by Island - May 15, 2020 18:49:18

Attachments:
SpiralExpression.hiplc (98.0 KB)

User Avatar
Member
4495 posts
Joined: Feb. 2012
Offline
#include "math.h"
#include "voplib.h"

float easeOutCirc ( float t )
{
    return sqrt ( 1 - ( pow ( ( 1 - t ), 2 ) ) );
}

float index = @ptnum;
float numpts = @numpt;
float startAngle = radians ( ch("angle") );
float dir = 2 * ch("dir") - 1;
float steps = ( numpts - 1 ) / ch("turns");
float stepAngle = ( 2 * PI / steps ) * dir;

float inc = index / ( numpts - 1 );
int mirror = chi("spherical");
float linear = ( 1 + mirror ) * inc;
if ( mirror && index + 1 > numpts / 2 )
    linear = ( 1 + mirror ) * ( 1 - inc );

float circ = easeOutCirc ( linear );
float interp = linear + ( circ - linear ) * ch("roundness");
float r = ( ch("rx") + interp * ( ch("ry") - ch("rx") ) );

//  Apply power to radius at the end (after curvature)
inc = ( ( numpts - 1 ) - index ) / ( numpts - 1 );
float theta = 2 * PI * inc;
if ( mirror && index + 1 > numpts / 2 )
    theta = 2 * PI * ( 1 - inc );
r *= pow ( ch("falloff"), theta );

float angle = index * stepAngle + startAngle;
float x = sin ( angle ) * r;
float z = cos ( angle ) * r;
float h = index / ( numpts - 1 );
float y = vop_bias ( h, 0.5 * ch("bias") + 0.5 );
y = vop_gain ( y, 0.5 * ch("gain") + 0.5 ) * ch("height");

matrix3 xform = dihedral ( { 0, 1, 0 }, { 0, 0, -1 } ) * lookat ( 0, normalize ( chv("n") ) );
@P = ch("scale") * set ( x, y, z ) * xform + chv("t");

Create a line and copy this code inside a point wrangle node. Make sure to set Scale, Height, Ry, Falloff to a positive value like 1, Turns to 5, N to {0, 1, 0} if your input line is along Y. It can also create spherical spirals, etc.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
670 posts
Joined: Sept. 2013
Online
Or this:

float u = vertexprimindex(0, i@ptnum) / float(primvertexcount(0, i@primnum));
matrix3 m = ident();
float amount = chf('amount') * u;
vector axis = {1,0,0};

rotate(m, amount, axis);

v@P *= m;

Attachments:
spiral.hipnc (74.8 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
340 posts
Joined: June 2017
Offline
There are probably more elegant ways of doing this (and more mathematically correct), but here is an unwrap of a spiral with reasonable UV's. Note: due to changing number of points on spiral curve, the transform UV scale had to be keyframed on the extruded spiral. There is probably a simpler way of doing this, but I don't know it. The length of a spiral curve also does not have an exact solution in calculus, so I made a few approximations.
https://vimeo.com/420120985 [vimeo.com]
Edited by Island - May 19, 2020 13:55:38

Attachments:
SpiralUnwrap.jpg (1.1 MB)
SpiralUV.hiplc (672.8 KB)

User Avatar
Member
340 posts
Joined: June 2017
Offline
I actually think Konstantin's method is better than mine (and Animatrix's method is particularly good for more complicated spirals). In mine, the ramp actually compresses the material during the unroll, which is undesirable. I modified Konstantin's method slightly, but I'm not sure how to get the UV's to map properly, but the shape itself is great. If anyone knows how improve the UV mapping, I would be curious. The only thing I can think to keep the UV mapping correct is to actually unwrap the spiral, using the method described in cgwiki.
Edited by Island - May 21, 2020 10:41:27

Attachments:
KonstantinMethod.jpg (907.5 KB)
spiralM2020.hiplc (546.1 KB)

User Avatar
Member
670 posts
Joined: Sept. 2013
Online
I have improved the code and updated the hip file to illustrate it's working on multiple curves at once. As opposed to the usual @ptnum / float(i@numpt - 1).

int seed = chi('seed');
float u = vertexprimindex(0, i@vtxnum) / float(primvertexcount(0, i@primnum) - 1.0);
float turns = fit01(rand(i@primnum + 12 * seed), 0.1, 1.0);

matrix3 m = ident();
float amount = chf('amount') * u * turns;
vector axis = {1,0,0};
rotate(m, amount, axis);

v@P *= m;
Edited by Konstantin Magnus - May 21, 2020 07:33:45

Attachments:
spirals.jpg (28.9 KB)
spiral.hipnc (84.5 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
  • Quick Links