Jump to content

particles to follow a sine-wave shape?


watchman

Recommended Posts

In order to now use "distance" parameter AND sine/wave on velocity I had to post-multiply cosine function with some - you will be laughing now - magical constant value (in my case it was approx. 0.93) in order to correctly align velocity to sine/wave. It's working with this little hack, but I'm sure there's a proper way to do it.

OK, so with the time-based sine wave, we could calculate the time derivative pretty easily (using the chain rule)

y = A * sin(F * t)

dy/dt = A * F * cos(F * t)

But now you're not using time directly in your y function, you're using distance, call it s:

y = A * sin(F * s)

but to correctly update our velocity vector for each point, we're still looking for velocity, i.e. dy/dt, even though the function is now in terms of s (distance) not t (time).

So, how to find dy/dt, given a function for y that contains only s? Another way of writing the chain rule is as a product of the separate derivatives:

dy/dt = dy/ds * ds/dt

We can calculate dy/ds easily, it looks just like the function for time above but with an s in it:

dy/ds = A * F * cos(F * s)

This is what you're currently using as your velocity, but as you can tell, you're missing another term: ds/dt. So what is that? The distance traveled is a (probably non-linear, and unknown analytically) function of time, so it makes sense to talk about the derivative of it with respect to t: ds/dt, the rate at which distance traveled changes relative to time. Well, we have a name for that: speed.

So ds/dt is just the speed of the particle at that given time step, and the speed is just the length of the velocity vector. So:

dy/dt = dy/ds * ds/dt

dy/dt = A * F * cos(F * s) * length(v)

Your magic constant probably almost worked because it was close to the average speed of your particles.

Edited by johner
Link to comment
Share on other sites

  • 2 months later...
I vote for number 1. We're back to the calculus from early in the thread. Since you know exactly what you're adding to the position parameter, you can calculate its first derivative (velocity), transform it by the same rotation matrix you're using for position, and add to the incoming velocity vector. See messy network attached and hip file.

Two points: the default "from" parameter in the LookAt VOP is not (0,0,0) like I thought, so make sure it is in your VOP, or do what I should have done in the first place and put a constant zero vector in there.

Also, I would think about using sine for your position like I have here, rather than cosine. The reason is that sin(0) is 0, while cos(0) is 1, so at time 0 you're getting an offset immediately if you're using cos. You may want that. The setup I have here uses sin for the position, so:

y = A * sin(F * t)

dy/dt = A * F * cos(F * t)

if you do it the other way, make sure to negate the amplitude in the derivative:

y = A * cos(F * t)

dy/dt = -A * F * sin(F * t)

So i've read this topic a few times now, and i think my brain is just kind of tired or it's my lack of "remembering" all the math, but i'm having the same issue with motion blur, where, i have a pop net, and then i build a custom noise vop, then when i render, the motion blur is wrong, because the velocities are not "updated" by the "custom noise vop"...

i know you went pretty deep into the math but i still got a bit lost. could you help explain it to me? I'm not sure if i should be doing this calculation inside the custom vop, or outside. my thoughts so far are:

i need to create these attributes:

"velocity" before custom noise vop... (which is already there)

position before custom noise vop... (which is already there)

then it seems like, inside the custom noise vop, i need to get the difference between the "position before entering the custom noise vop" and then the "position" after the *noise manipulation*, then i need to take that information, and then... that's kind of where i get lost. i know it involves some kind of math on the current velocity and the "distance traveled ---referring to the distance between the current and new position*... to get the "new velocity"...

so:

$NEWVELOCITY = $CURRENTVELOCITY (some kind of math) ($DISTANCE)

(i know that's pretty weak but that's all i got!)

hope to hear back from you,

thanks so much

Jonathan

Link to comment
Share on other sites

If from velocity and time(frame)

$vel.x = $speed;// const

$vel.y = $amp*cos($Frame*$frec);// Derivative sin

$vel.z = 0;

thanks for the example, however, i'm not sure this is what i was looking for. i'll try and explain better:

i have a popnet, *with all of the forces etc... in a very noisey fashion, not a "simple sin" wave*

after the popnet, in SOPS, i created a custom noise vop... the vop is pretty much just a "turbulent noise vop"..., so when i apply this to my "points", they get even more "noisey"... which is what i want. so the look is how i want it. i already have that. but the issue is, from my POPnet to my Custom Noise VOP SOP, the velocity information is not "updated".... they still have the same velocity information they did from the "popnet"....

i've attached my .hip file... *you can essentially ignore everything but the POPNET and the custom noise VOP....* all of the other nodes *attribute_creat, time shift, point* were failed attempts at trying to get the "NORMALS to point in the correct" way, and to get the velocity information to be updated.

no luck tho. i went the route of even trying to just get the normal pointing the correct way, which i thought would be a simple, *position in x, y and z from last frame, to position x, y, z of current frame*, which should draw a line and be pointing in the direction the point has gone.

but didn't seem to work!

thoughts and help would be much appreciated. thanks much

J

noisey.hip

Link to comment
Share on other sites

In your project after popnet is vexnoise, which P = noise, this resets all efforts popnet, be done P = P+ noise, then vexnoise will change but not replace, the points position. Velocity can be calculated using trailSOP or vopSOP where vel = P(frame+1) - P P(frame+1) created using timeShiftSOP

noisey2.hip

Link to comment
Share on other sites

In your project after popnet is vexnoise, which P = noise, this resets all efforts popnet, be done P = P+ noise, then vexnoise will change but not replace, the points position. Velocity can be calculated using trailSOP or vopSOP where vel = P(frame+1) - P P(frame+1) created using timeShiftSOP

Very nice chumbuk. TWO solutions... and i was playing around with a THIRD, that seems like it works. i'm not seeing any errors and the velocities match the velocities in your example... but inside of the "vex noise*, i just added the "incoming velocity" to the "output of the noise", and then plugged that into the "OUTPUT VELOCITY"... and that seems to give me the same numbers as your two solutions also. thanks!

J

Link to comment
Share on other sites

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...