-
Decaying bounce with increasing frequency ?
hi all
I’m trying to write a decaying bounce function that more closely simulates real physics than than classic decaying cosine wave. I’ve done quiet a bit of searching online and most of the maths (derivatives ?) is way over my head. I don’t need it to be a perfect simulation but I really need the frequency to increase over time.
I’ve tried various, increasingly baroque, options and spent way too much time in Grapher but most of my solutions will only work for a limited set of variables, change the input for decay or frequency by too much and stuff starts wigging out at the end.
any advice on how to tackle this would be greatly appreciated.
cheers../Daniel
below are examples of the code I’m currently working with (apologies for formatting)
a) the simple Cosine decay, time between bounces is constant
b) my best attempt at introducing an increasing frequency so that bounces start to speed up// simple exponential decaying bounceamp = 150;
decay = 0.5;
freq = .5;
x = time;eDecay = Math.exp(decay*x);
cosPos = Math.cos(Math.PI*freq*2*x);
absPos = Math.abs(cosPos);
decayPos = absPos/eDecay;
posY = amp*decayPos;
posX = 100;
position + [posX,-posY]
// exponential decaying bounce with increasing frequencyamp = 150;
decay = 0.5;
freq = .15;
x = time;eDecay = Math.exp(decay*x);
cosPos = Math.cos(Math.PI*freq*2*x*Math.pow(1.3,x)+(2*x));
absPos = Math.abs(cosPos);
decayPos = absPos/eDecay;
posY = amp*decayPos;
posX = 100;
position + [posX,-posY]