### 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

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 666.3oc2XssbaBCD8Y7WACSeHoCgpKbsu0uilNcHF4D0AKnH4INMS92KHAIg D6wxbQwNuHOrZQ6QGsmUd4wEVN2Trkvcr+t8OssrdbgkkzTiAq1msbVmtcYd JW5lyZBmmdKwwUMmfrUHsC7bsgd1A..naN1l0TVNQHeQTqwxTwx6nra+cEYo PEXePjGv0NA1LFD2LBC8.1+5k0oXinagfsVoYx3VbyetBF0ExUELAm9OhzQP 8JoLqdcwCkDUDcbddwKqHbBSjJnEr8gIP6vyuTSXXoqkqlyOpno4NMS7zhEM CtZRkLx80n+cLYNkQpi1NYQ7AYQHTBY+P4Cw6kFQ6fFiOZZzUeprEXlkKIaK qpSKuh+2JwE0+VVb+EeYE75qcQdWd4NoX3goXLV8C5.b7tRUSFdp5zvTyf.F qHjDzfEv9St.tGlNKDvsHFBQCV.GLKB39.yrbYsf012afIjPrujJACPmFdrT 4p7hTwYfXEEMVwJbxEq8vzYgXsEwiQrhlEwZefYdwJ1afIjiQrh+zJVkahQH Vim9KVgxyoD74iVUQhiPqlLO2qpXRHD+wHUQdCLcbLRUvmUoZT33TpQezMFL shNEcLBM2H+urSTdxlbAkmSyHUGayhHnrYQDLQt2UeIAHBbLbvysEwq8Q7PN 409sOBXh6dlSYMsL+UrGzGFjfB+VcqyGKYzlMnpa.QwCnvwbIOjtIyxey2AS tMZr2m33EapV1EjtOah8K6jLBWPYxZ8u1ojdNcGMKiHmuC+qoYkETlnED64X TaLknAl7MKjhzglhMKlBO8no.cnoPyhIecvTfYwD9z6nCoCMgMKlf5fIjYwD 3j6nSmxkuA1yMjz4VEydohNEvMaQ.spUZ1b6YN0t9gmV7ePnFA0V -----------end_max5_patcher-----------

> 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?:

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 523.3ocyU00biBBE8Y8WAiO6xvELFXeq+N5zYGaj1RGEyJjooam9eeAhlX2M 1Qq8qGLFubANmy8dfmhiRttYuzjf9I5RTTzSwQQgP9.QceGkTWreSUgIjVRs zXJtUljdXLqbuMDGvoHBFQWQH8i0ryVIs1G2JOrAIInq5FRUFlTy02+C.5y+ lFsUWTGxN4hVUQU+H5c0JsasBPfNHci5OgzABlbJ2CabHYnK51B6l6T5a+Uq bi8.bn7bbNKmwYoHAESDDAPSQq3tkBA4XB5J+beNN1+S5D0Gs7AGq9O4oRok N8YboIs64rRDclRDaNRDaZRD.TuvjkGjG96q7X9cqcTs4lplB64EF1LEF3Cn 2Ax7K.htdQByX9JhyWAuEeE+qxV4ljyJQ37u61JwWkqZfB8g5p117.h9VrUj uA8Nc1J1BsU6prJSkpT195MImSGxd0yPdIqnSiUTPD3i.BunDOu5lpwsT1Gq BvhNfqgDBs5+yM0g8xG+kBfoYW6ldx00nifiaSozXU5BqpQOHG+0vnSX4NUY oLLdeQrVUtsQoscXfxXmJUrL7ZfrlI7GCli4qDYh0iGmyvYt349vhbLzcP5w viTomJc82JLfJmmuYyjtCvIkPvbZdFCb+2UAy5qsGiuPBHl.98dz4Pfkpozo fI1mKlHu+04EBI9DPj3yUjfoT3nK.StOdN9uLKFwIC -----------end_max5_patcher-----------

Hi!

There are some easy ways to do limited functional programming.

Here is your line example using "set’ with grab.

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 1046.3oc0XssbapCE8Y6uBFd1GORaIAn9V6mPaeqSmyfAkT5fAWPdZxoS+2O 5B9Vhk.RrINuHGT3xRq8R68R6+LeV3p5GDsgAeH3aAyl8m4ylYlROwrtqmEt N8grxzVysEtVz1lduHbg8+IEOHMy2Jq2raxpsqKpJERyS.cStIUl8ihp6+2F Qlz9EAdzRzhfXpdj.KYKBvpYB9d2iTjad00q94+vhN5kWuUt6si6l8t5JYU5 Zg4A9XSQZ4t62dyxG2Hrezvv8ue8C0V7el+AFsDom8uymqGVLP5Hqd8ZQk7Y zwW95G+7WOKefcyGQTCePX5QJQOhSbvGzyyGnd4iKvhd0VortZrqNVhcEYh1 Q6GO6pC7GseVLcUZ08GhqaZDspfRprnt5H.Pob8GELjLpaH36u.Bv4l.gLXS 8uEMMJ7HZZG6FBVBZIGwQrDEOEqvo5BLrHHIwvbN1aPStM2aTI9sBdOijVE. iV5nRNrmWXlPWTrIcgqsGnySIv3oDizZw.kXQj3C.kSNUnc4XVW5Ob.vPnQq 5TraDIhvHmp5nXepNF9Jn57Pq6PHfOfvqA25P0l8XVoX7JWhJo2dAAvsDZhu L6T1ES5pksSR0trzxxfGq21Db21pLcvqczDkJDqSNSLjCm6khPis3WvmpKyC u9DQt3thJwqjJRL0+AvJSvd8APRdqoBe0Bap2VkO1zQTB9nhfj8a1YfuzQPx TlNhtGg.fdKRG03gaQdjVIFfmno1DS5cJ3SdAz2UVKZ+Uibz61NPI.xXMDh8 RIrKFkbWYcpLbRTK85JcfhFv3aO1aELf7tRznnFG00ggwILSFZheUC79S0r5 UZ2YHF0wwWYi5WwJbnWjaaMEcvsMYftswQSW4MJmtGgQuIU2J0lnPKOK0R70 OI1A0Gxlix1hIWxOGrJ4E50dwPXWZzgTGXz05HhNX16aRWEf6ub.dXrrw8il r8ZRM91rdv5skxh1xhbQyqhCrFovb6O.xwNXp+Lc8b5sAnl.b7YUSJm3sxGK MuW3EvSaRqDkitWlL6oWr+zcVFv0oXbrODMUnEhsN+PcmP2ZMN1AZ49Oykyz pVtfib1+QyWyj86I8j2.Y87mtvaUmyLamdYWaxCN.5bQqrnx.jitoSumeTjm KpNF+qKx2TWTI6vfiNjNXHAC.R590MkXBeAnor5x5F68iVBDNfizQzH04WIw 5+JFwSPTUD+HYzSVGL0wuv6LCXa5QTm45SthaFIH1RZWVGdhydWOTVP223dY g3oMvn0A3dfzSv80FS5Fx0KllZALZHapvSOO0GlvSqdJZHxI1jBo3gvRzIER vsWhfnaNDo6pQuPBfIESlcS8ougjoGS8JvmVOH.cHwtoMO.N5FwCBgSdtGD9 IdP3CzCh5h+N++UPhVGK -----------end_max5_patcher-----------

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.

**all**of the following text. Then, in Max, select

*New From Clipboard*.

----------begin_max5_patcher---------- 1035.3oc0XssiqZCE84juBJpOxAYarM3914WncdqpphP7Lia4lBN5LoGc92q sIDfLjfCCPmNRgK1LvZu1q8xW991Mt6JdiW457KN+tylMee6lMllzMr478ab yheKIMtx7XtIEYY7boqWceR9aRS6Oc3jSrS0IUuR0kEkRQQ9O07X4GyJNJS4 RyKAbtUwdy+Zwt+5K3lm74hbYdbF2zyWOHhSa5oLVl7pH+k+7.OQVCYXXnOv ScJvbBRpuyG37GcdcUh+w75X9PJ.xhZwjHuARPca+X6V8AOKoB0KXG+PC7Tc IxNlo6AMXTideTCAiG10uA4oRdcL6Jzrui6t37WbuDm6dIoHs3P8i.7inp+B 8F7JXG5QdPTkDmZd0.e1cXZLnlaQ5SAODQ+pVjzGdg.RTj2fW0EdpDTCmBlq rVFupJ9E96DvJoqyOCGVvBGH0AmPpqMecGJlYHWrgn0J5GVKil.qbTUTeb3f O3bqow63oIohj+9FTRzzEylespRU+mMktGgEE0kuBeDIoPxyN+EbSE45Oum9 .+sxKWWV7sVHsbxNYQo0hNBctEcHFUyagXSYMxmn3P5M3PnVeNS5saMLxu8z W+0mrdTCxzF1fR53hgqG6H5AC5onA1cTJKxsOaitYNsu4+.gHIhYBKSdkd43 7omy4eSgw2k+r2.EOU6h6G1pQw.L0HIZu.kPVcCDoR0vIkjQyGwryA4Z6zBH SYZAFIgmMRCUY9ENhXFygFZJ7WiZfa4CBcPD.v9ZiYe3WMsPCnAjf9RGbszg 9emzI4TRJ+AjOXxT3FuQ3mfnfVYCp1cgFsZdm2fa9h8FNnkvvAqbVZMbBZMb .+exvAFtjFN8TNeZLb.OlgCb1m5klVZMbB9DY3nlQLWshr6ubfNbCcp9MdiN 6TRqxAbd59zIUYELizSouZQyYkO6jEW5.bfle5kKXa81TJ2dNsHV9PLFBUaB MQuH5TJ1NlJEUoh8s6KxvjQk5d4o5MdXHCI7zGnpGEfqUKr5ZJMgL9TfMOgo H3pcFy7wzs2mApJNdHoAdmWHrRPz7c1yqjh7X89g04YTR.mVr7pX+ddd2U4j I1WVnF84LDfPn1wDAMwS.f3iaBwZmhASV1BX8lYzAMyChwrkDw.KP7Ug0nP9 ChI57ShePDEZCIgWUHomElUrDwdHgUCYdQbALqmGqzX8Z5CBa7B.aBCrzvVu RxQshtJ1VZEfdxlihIzJiIapcoi.odawMJfo74zarMUsFg.yNvGBXQ.70awc u3HfE3CalTHiUOW45Ea06NVz0tprnOtopU9EzU2TcTALYUgzUetaPSqqSOwl wCIv0mmFK2cEvWbdB9IoPmfQuuPOpWgdzhUnq2Y4wUKqblYNrfuGjT27is+a gLous -----------end_max5_patcher-----------

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’.

Forums > MaxMSP