Maths Question

   1461   2   0
User Avatar
Member
141 posts
Joined: 3月 2016
オフライン
Hello - I'm wanting to animate some points moving in and out along their normal over the course of 10 frames.

I can do this using a sop solver with this:
if (@Frame % 5 == 0){
  i@move *= -1;
}else 
@P += @N*i@move;

However i'd originally wanted to do avoiding the solver and using sin() but have trouble figuring out how to refit down to just 10 frames... a maths black spot.

So I can change the -1/+1 of a sin wave with
fit(sin, -1,1,0,1);
but how do I alter the speed to move 0-1 over 10 frames, repeatedly?
Love Houdini
User Avatar
Member
9402 posts
Joined: 7月 2007
オフライン
the speed of the sin values changing is dependent on how fast the angle is changing
so making the angle depend on frame and doing full 2*PI rotation in desired frame period should give you the result you want
float period = 10;
float sin = sin(2*PI*@Frame/period);
float offset = fit11(sin, 0, 1);
v@P += normalize(v@N) * offset;
Edited by tamte - 2021年10月5日 11:24:05
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
141 posts
Joined: 3月 2016
オフライン
Fantastic... thank you Tomas.
It seemed like it should be quite simple, but couldnt quite get there.
much appreciated
Love Houdini
  • Quick Links