Prabola equation on point @P.y values

   3982   9   2
User Avatar
Member
5 posts
Joined: Dec. 2016
Offline
Hello, Houdini fellas!

You guessed it, I'm still very new to Houdini hence my question is probably basic.
I watched this fantastic tutorial –> MC Versus Vista [youtu.be]

And I thought to give it a try at the electric pole wires, it should go something like this:



I tried to do a simple solution with VEX like and I stumbled to few problems:

Is it possible to write the coordinates to all points like:

@P.y(previous point) - increment

can vex read the previous point @P.y value and how?
I can't seem to make a for loop work on points
e.g.
for (@ptnum = 0 , npoints(0), 1)
{do @P.y stuff..}
Edited by TheBlues - June 4, 2018 13:10:43
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Yes.

Attachments:
Parabola.hiplc (65.4 KB)

User Avatar
Member
5 posts
Joined: Dec. 2016
Offline
Thank you, sir!

Your example is very helpful for getting the idea of plotting a parabola graph.




I was looking for a solution for a case like the one in attached file.
Edited by TheBlues - June 4, 2018 16:00:52

Attachments:
Parabola_example.hiplc (70.8 KB)
Parabola2.jpg (130.6 KB)

User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
I changed your primitive wrangle to detail wrangle where you create the line.

As you had it you were running over primitives - so for each primitive you created another new line.

Of course if that's what you want, then some extra code just needs to be put in to put in some variation in the ‘sags’ for each wire.(I looked at the video you link - seems like you might want to something like telephone wires?)

Anyways, in the last node of you file I put a wrangle - in it there is a folder tab called “Wire Sag Control”.

In it is the ramp to shape the wire sag however you want.
Edited by BabaJ - June 4, 2018 17:07:35

Attachments:
Parabola_1.hiplc (77.9 KB)

User Avatar
Member
7755 posts
Joined: Sept. 2011
Offline
since parabolas are scale invariant, you can simply add an x^2 to the y value, with x being the uniform parameter of the line. No detail wrangles, no looping over primitives, unless you like slow things.

In a pointwrangle:

float u = vertexprimindex(0, @vtxnum) / (primvertexcount(0, @primnum) - 1.0);
u = 2.0*(u-0.5);
@P.y += -1*(1.0-u*u)*chf('scale');

If your curve was generated with a resample sop, you can even replace the first line with float u = @curveuif you enable “Curve U Attribute”.
User Avatar
Member
5 posts
Joined: Dec. 2016
Offline
Wow, that's exactly what I wanted to do!
Much appreciated.
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
No detail wrangles, no looping over primitives, unless you like slow things.

What do you consider the reason using the detail mode of a wrangler to create his prim that makes things slow?

In his particular case (staying in the contex of his setup) the only other option I see is to use an add node.

But when you do that along with your code vs. mine with the detail - according to the performance monitor, your solution is slower.

Attachments:
Parabola_2.hiplc (116.3 KB)

User Avatar
Member
7755 posts
Joined: Sept. 2011
Offline
A detail wrangle is single threaded, whereas the point vop is multi-threaded. The idea is you can create thousands of lines, doesn't matter how because it won't be the repeated part, and use the pointvop to move points after the fact, which will probably be a repeated operation as sagging amount is either animated or art directed. The point vop stays fast even with hundreds of thousands of lines.

In this example 200,000 cables sway in realtime. The cable generation part is maybe not the fastest way to go about it, but since it's not animated it not the focus for performance improvement.

Attachments:
sway_cables.hip (538.8 KB)

User Avatar
Member
7755 posts
Joined: Sept. 2011
Offline
If you make it a proper test with lots of cables, you can see that looping over the points in a prim wrangle is an order of magnitude slower than the using a pointwrangle.

Attachments:
Parabola_2_compare.hiplc (150.8 KB)
primwrangle_vs_ptwrangle.png (196.2 KB)

User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
But the example was to only create one line, multiple threading isn't applied in such a case.(reference the detail mode wrangle)
Edited by BabaJ - June 5, 2018 13:23:38
  • Quick Links