interpolation methods in expr
These are the times I wish I'd taken a single math course in college. I'm wondering if anyone can point me in the direction of various interpolation equations for use in expr.
I know there are objects for linear (line) and logarithmic (slide), but for starters they take different arguments so it's difficult to toggle between them. I like the way line works best (spitting out all the numbers on the curve in a specified timeframe), but would be open to whatever makes the most sense from a programming perspective.
Secondly, I'm interested in other types of interpolation, particularly quadratic, which seems popular for tweening in animation, essentially what I'm using this for. I'd also like to be able to "ease in and out"- also a common setting for tweens. Any help would be greatly appreciated.
Many thanks,
Zach
I may have posted this a little prematurely. A little more research found Robert Penner's easing functions for Actionscript: http://www.robertpenner.com/easing/.
It seems like I could almost plug these verbatim into the js object. I believe Max uses the same JavaScript implimentation as Actionscript 3.0, I just don't know if the changes from 2.0 affect this code.
Regardless, it would be very helpful to see anyone else's tweening patches. And if anyone from Cycling is reading, I think there would be much demand for something like a multipurpose tween object.
Implementing the math given in these examples is really straightforward using regular Max objects. The same equations/functions can be applied to jit.expr/jit.op or similar MSP objects (pow~,cos~,sin~,etc.).
Best,
Andrew B.
Sorry, forgot to paste my example patch...
AB
> Secondly, I'm interested in other types of interpolation, particularly quadratic, which seems popular for tweening in animation, essentially what I'm using this for. I'd also like to be able to "ease in and out"- also a common setting for tweens. Any help would be greatly appreciated.
>
> Many thanks,
> Zach
----------------------------------------------------
You could also use [pattr] with table interpolation, and simply fill your table with whatever curves/fades etc. you want, get a bunch of good ones, and preset them. Use [uzi] and the right expression to fill the tables with (for example) 2*sin(3x) or (ln(x) * 0.5), etc. etc. You can see the results right away using the number boxes in the scalars/exponents. And you can always just draw in the tables you want, though seeing the functions draw out is cool :)
Wow. Thanks, Andrew. I can't believe I thought I had to reconstruct the equation for line rather than just modulating it with some math. It's funny, I've been using Max for over a year now and still think in terms of functional programming to the extent that these simple solutions always elude me.
Anyway, so a quadratic ease-in ease-out for something like a ball bouncing would look like this?:
Hi!
There are some easy ways to do limited functional programming.
Here is your line example using "set' with grab.
You may also want to look at lp.scampf and lp.scampi from the Litter Starter Pack. They are scaling utilities that you could describe as "scale on steroids". The letters 'scamp' stand for 'scale and map', with scampf producing float output and scampi producing ints.
They produce the largest variety of interpolation methods you can get off the shelf. And probably more than most people would take the time to patch together. Worth a look, if I do say so myself.
The Litter Starter Pack is available at the link in the .signature.
Hope this helps,
Peter
OK, here's a version of the above patch that does it all (and more) with lp.scampf. Enjoy.
Oliver, it's hillarious how convuluted it looks to try and replicate functions in Max. I think I just need to learn to keep it simple and go with the dataflow.
Peter, that looks really cool, but there's no way I would pay for an external to do simple math. Maybe they do more than I'm noticing, though.
Thank you, Julien.
Zach: let me repeat that lp.scampf and lp.scampi are part of the Litter Starter Pack. The Litter Starter Pack is available at the link below in the .signature.
I do make a concerted effort to underscore which objects are in the Starter Pack and which are in the Pro Bundle, and that the Starter Pack is free.
That said, the symmetry equations in scampf and scampi go beyond what most list readers will reckon as 'simple math'.