Last active
August 1, 2019 05:57
-
-
Save makoConstruct/4c5376b50d362ee5fecfe2e3b2240cff to your computer and use it in GitHub Desktop.
A thing for sort of averaging a quantity over time with just a single float
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const float MemerPower = 2; | |
struct Memer{ //where p represents the pulse magnitude and delta represents the amount of time that has passed since the last pulse, the Memer sort of remembers the last couple of pulses and how long ago they were. For any consistent p, d, Will arrive at an equilibrium v that is higher if delta is lower and higher if p are higher. And I think- I'm not sure of this but it seems like something like this will hold- I think that for any a,b p,d where a/b = p/d, if you keep pulsing (a,b) and (p,d) they'll end up similar? | |
float v; | |
Memer(float v = 1):v(v){} | |
void pulse(float p, float delta){ | |
float xof = log(v)/log(MemerPower); | |
v = pow(MemerPower, xof-delta) + p; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment