Jump to content

Wobble (rotate) points on axis using VEX


TobiasSteiner

Recommended Posts

Hi guys,

I've been giving VEX a go recently and I've hit a block in something I'm trying to achieve.  I'd like to take a set of points from a scatter node and wobble or wiggle each of them randomly on a given axis (Y) over time.  As an expression this is as easy as sin(time * #) in the rotation transform for a desired axis.  This doesn't work in VEX as everyone knows.  I did find a lot of reference on matrix and quaternion functions in VEX and this seems like the way it should be done.  It looks pretty complicated though for something as simple as wobbling a point on an axis.  I know VEX works with radians only.  Anyway, I'm sort of stuck.  Any help would be appreciated.  Thank you!

 

Link to comment
Share on other sites

I must be missing something, as it seems I don't know what everyone knows  : /

why wouldn't that work in VEX ???

I just did it quickly, and it does work.

a sphere

a scatter

a wrangle with @P.z += 0.1 * sin(@Time + @ptnum);

and all points "wobble" on Z axis.

 

*edit*

oh ok, you're talking rotation !  my bad... now I gotta try ;)

Edited by 6ril
  • Like 1
Link to comment
Share on other sites

I'm pretty sure this can actually be done in vex.

are you talking about rotating points around a certain position, or rotating a vector itself (for instance a N value of a point)?

for the first one, I would think you would need to go 3 steps:

-save original position, and temporarily move the point to a position so it is relative to {0, 0, 0} as the rotation axis.
-rotate the point around the origin.
-add the original position back.

for rotating normals, if you want to make them rotate around a single axis, that should be simple enough with matrices, or even atan2 + cos + sin maths.
If you want to expand that for multiple angles, I guess you just have do a rotation over the perpendicular axis, and use that as the axis for the primary rotation.

Then finally you could "randomize" the rotation speed by layering a couple of sine functions on top of each other for instance.

 

Link to comment
Share on other sites

2 minutes ago, acey195 said:

I'm pretty sure this can actually be done in vex.

are you talking about rotating points around a certain position, or rotating a vector itself (for instance a N value of a point)?

for the first one, I would think you would need to go 3 steps:

-save original position, and temporarily move the point to a position so it is relative to {0, 0, 0} as the rotation axis.
-rotate the point around the origin.
-add the original position back.

for rotating normals, if you want to make them rotate around a single axis, that should be simple enough with matrices, or even atan2 + cos + sin maths.
If you want to expand that for multiple angles, I guess you just have do a rotation over the perpendicular axis, and use that as the axis for the primary rotation.

Then finally you could "randomize" the rotation speed by layering a couple of sine functions on top of each other for instance.

 

Thank you. I'm really just trying to make each point wobble randomly on a chosen rotation axis. Think a flock of birds gliding in the X direction and each bird wobbles slightly on its X rotation axis in a sine range of 10 degrees or so.

Birds, planes, or pigs....whatever the flavor. 

Link to comment
Share on other sites

11 minutes ago, acey195 said:

so like a "slalom"? using a solver? 

Actually that's almost it but not quite.  Think of an aeroplane that wobbles slightly on its X rotation axis while it's flying down the X position axis.  A slalom is more like a sine along the Z position axis with banking on the X rotation axis while moving down the X position axis. 

I think I got that right.

But the goal is to do this in VEX.  No solvers.  No VOPS.

p.s.  Here's the start of the VEX that gets the points moving at "random" speeds along a chosen axis with user controlled speed.  Part B of this setup is to get those same points to wobble in their rotation axis of travel.

@a= fit01(rand(@ptnum), ch('slowest'), ch('fastest'));
f@b = ch('speed_rate');
@c = (@a * @b);
@P.x = (@c * @Frame);

Edited by TobiasSteiner
Link to comment
Share on other sites

I got it!!!

Stay tuned.  Cleaning up then I'll share. :D

 

Here it is:

vector normal = normalize({0, 0, 1});
@N = normal;
@N.y += .1 * sin(@Time + @ptnum);

@a= fit01(rand(@ptnum), ch('slowest'), ch('fastest'));
f@b = ch('speed_rate');
@c = (@a * @b);
@P.x = (@c * @Frame);

This does EXACTLY what I was trying to do.  I'll mess around with it some more to get user controls added for specifying axis of direction and wobble.

Thank you guys for your help.  It actually helped me come up with the solution ultimately.  Grateful.  You rock!

Edited by TobiasSteiner
Link to comment
Share on other sites

Just now, 6ril said:

weird, reading you code I feel it would just make points travel on X axis at different speed.

That was the initial code. Drop the updated vex on a point wrangle after a scatter then feed that into a copy of some small grids. You'll see it work then.

  • Like 1
Link to comment
Share on other sites

30 minutes ago, TobiasSteiner said:

vector normal = normalize({0, 0, 1});
@N = normal;
@N.y += .1 * sin(@Time + @ptnum);

@a= fit01(rand(@ptnum), ch('slowest'), ch('fastest'));
f@b = ch('speed_rate');
@c = (@a * @b);
@P.x = (@c * @Frame);

that's the only code I see, and I tried it, in case ... but it's doing what I thought.. move along X  as you're only affecting P.x

maybe I don't see the updated code (I refreshed tho)..

 

 

 

Oh ok .. I see now. I didn't get it, because I was not thinking that was what you were trying to do.

just sin that N  :)

Edited by 6ril
Link to comment
Share on other sites

7 minutes ago, 6ril said:

that's the only code I see, and I tried it, in case ... but it's doing what I thought.. move along X  as you're only affecting P.x

maybe I don't see the updated code (I refreshed tho)..

 

 

 

Oh ok .. I see now. I didn't get it, because I was not thinking that was what you were trying to do.

just sin that N  :)

Exactly.  That was the part that I wasn't seeing at first.  Houdini thinking is a bit different in certain ways than with other 3D apps.  The gotcha is that the scatter node does not create point normals so you have to recreate them afterwards.  I added the file here in case anyone ever comes across this problem and wants the solution.

VEX_Axis_Motion2.hiplc

Edited by TobiasSteiner
added file
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
On 3/4/2017 at 7:01 PM, 6ril said:

I must be missing something, as it seems I don't know what everyone knows  : /

why wouldn't that work in VEX ???

I just did it quickly, and it does work.

a sphere

a scatter

a wrangle with @P.z += 0.1 * sin(@Time + @ptnum);

and all points "wobble" on Z axis.

 

*edit*

oh ok, you're talking rotation !  my bad... now I gotta try ;)

Hi, i like that little wobble sin code. Any way you could tell me how to make that loop on points please? I tried it on an animtion i have with scattered points that lasts 20 sec at 30fps, but i can't find a way to make it loop so far. 

Thanks. 

A.

Edited by Adriano
Link to comment
Share on other sites

  • 2 years later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...