TobiasSteiner Posted March 4, 2017 Share Posted March 4, 2017 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! Quote Link to comment Share on other sites More sharing options...
6ril Posted March 5, 2017 Share Posted March 5, 2017 (edited) 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 March 5, 2017 by 6ril 1 Quote Link to comment Share on other sites More sharing options...
6ril Posted March 5, 2017 Share Posted March 5, 2017 well, I'm now interested in how to do that too. Quote Link to comment Share on other sites More sharing options...
acey195 Posted March 5, 2017 Share Posted March 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
acey195 Posted March 5, 2017 Share Posted March 5, 2017 so like a "slalom"? using a solver? Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 (edited) 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 March 5, 2017 by TobiasSteiner Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 (edited) I got it!!! Stay tuned. Cleaning up then I'll share. 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 March 5, 2017 by TobiasSteiner Quote Link to comment Share on other sites More sharing options...
acey195 Posted March 5, 2017 Share Posted March 5, 2017 Glad you figured it out, no problem at all 1 Quote Link to comment Share on other sites More sharing options...
6ril Posted March 5, 2017 Share Posted March 5, 2017 weird, reading you code I feel it would just make points travel on X axis at different speed. Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
6ril Posted March 5, 2017 Share Posted March 5, 2017 (edited) 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 March 5, 2017 by 6ril Quote Link to comment Share on other sites More sharing options...
TobiasSteiner Posted March 5, 2017 Author Share Posted March 5, 2017 (edited) 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 March 5, 2017 by TobiasSteiner added file 1 Quote Link to comment Share on other sites More sharing options...
Adriano Posted May 2, 2018 Share Posted May 2, 2018 (edited) 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 May 2, 2018 by Adriano Quote Link to comment Share on other sites More sharing options...
blendini Posted March 30, 2021 Share Posted March 30, 2021 thanks for this. i'm working on something similar but mine, i want to rotate/move points on the surface of the object i copied points to. like moving it on it's surface. i would appreciate a help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.