Jump to content
Sign in to follow this  
TobiasSteiner

Wobble (rotate) points on axis using VEX

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!

 

Share this post


Link to post
Share on other sites
6ril    52

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

Share this post


Link to post
Share on other sites
6ril    52

well, I'm now interested in how to do that too.

Share this post


Link to post
Share on other sites
acey195    109

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.

 

Share this post


Link to post
Share on other sites
12 minutes ago, 6ril said:

well, I'm now interested in how to do that too.

Yeah it would useful for many situations. There has to be a simpler way than what I've come across so far. 

 

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
6ril    52

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
6ril    52
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×