View Full Version : slowing frequency of a sine wave

03 March 2011, 08:00 PM
Hi everyone!. So I'm trying to animate a sine wave's frequency to make it slow down, for this I'm using a float value between 0 and 1 to multiply it to the frequency. However the resulting curve gets all funky and it's not what I was expecting. Could you guys take a look at the expression and help me find what is wrong or what should I do to get the effect??

pointLightShape1.intensity = sin(time*(lightCtrl.lightFrequency * lightCtrl.mult)*4)+4

And here is what I've got so far (the blue lines) against what I want to achieve (the ugly black lines... sorry about that) (

Thanks in advance

Robert Bateman
03 March 2011, 02:17 AM
Don't forget that sin() takes radians (not degrees), so if lightCtrl.lightFrequency is say 20, you'll be going from 0 to 2pi, 12 and a bit times a second. So just looks like a aliasing problem to me.

03 March 2011, 07:52 AM
yep, as rob said, your numbers just might be too big. if any of multipliers (lightFrequency, mult) is above 1.0, you're getting sin frequency higher than one frame.

you also might have a problem with your formula, if lightCtrl.mult should be an amplitude scale - in this case, you'd need to put it outside sin argument, like that

pointLightShape1.intensity = sin(time*lightCtrl.lightFrequency)*lightCtrl.mult*4+4

with this formula, when frequency is 1.0, you're getting sin period roughly every 6.3 (2*PI) frames. with frequency multiplier of 0.5, period becomes 12 frames, while 2.0 will make it period of 3 frames.

CGTalk Moderation
03 March 2011, 07:52 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.