-
Making expression start at a certain time.
This question isn’t so much about accomplishing something as it is me trying to understand the coding language.
I am using this common expression for a rotation pendulum effect.
——————————-
veloc = 7;
amplitude = 80;
decay = .7;amplitude*Math.sin(veloc*time)/Math.exp(decay*time)
————————————–I wanted it to start at 5 seconds of my composition so I added this conditional:
—————————————
if (time>5) {(the expression above)}
—————————————The problem was that because the pendulum expression uses the time as its input by the time 5 seconds has arrived the rotation has almost decayed entirely, so it just jumps to the end.
To get around this I thought for a second and on a whime I added “-5” at the end of the two TIME values in the equation:
————————————————————–
If (time>5)
{
veloc = 7;
amplitude = 80;
decay = .7;amplitude*Math.sin(veloc*time-5)/Math.exp(decay*time-5)
}
——————————————————————————–In short, it worked like a charm!
My question: is this the most practical way to achieve this result? I am very new to coding and while there is a ton of help out there nobody talked about this particular problem.Is there a way to write the expression so that the value for “time” in the swing equation starts whenever the conditional starts?