Structures through smooth

offonoll's picture

Sorry if this has been descussed but I haven't found anything around. I want to do some smooth with structures values. Smooth has a time property so I get external time to link the index but not success.

How do I add smooth from a structure? JS? unpack and pack?

Thank you!

cybero's picture
Re: Structures through smooth

Funnily enough, the music visualizer template contains a smooth structure JS

var array = new Array();
function (__structure outputStructure) main (__structure inputStructure, __number increasingScale, __number decreasingScale, __number time) {
   var result = new Object();
 
   if (inputStructure != null) {
      for (i=0; i<inputStructure.length; ++i) {
         var value = inputStructure[i];
         var lastValue = array[i];
         if (lastValue != null) {       
            if(value > lastValue)
            lastValue += increasingScale * (value - lastValue);
            else if(value < lastValue)
            lastValue += decreasingScale * (value - lastValue);
 
            array[i] = lastValue;
         } else {
            array[i] = value;
         }
      }
   }
 
   result.outputStructure = array;
   return result;
}

offonoll's picture
Re: Structures through smooth

Thank you Cybero! but I need a smooth inside an inter. That means that I need and index...

I have tried to work with merge structure from this thread

Imagine you have a wii and we want to track the movement. With a camera, I click on the wii setting a X,Y position on the screen (I have an origin) then I need to add the movement from the wii to that point. To do so, I need to add structure data to another structure data and respecting the index members for each iter. The merge structures chances the X,Y to all members and I need an index to that JS.

Here I attach a sample from Kris Harris 'Optical Flow' and a merge structure from Franz

I hope you understand the idea. instead don't hesitate to ask me. :)

PreviewAttachmentSize
off Spider net.qtz49.08 KB

toneburst's picture
Re: Structures through smooth

That looks like a useful little code-snippet. I'm adding that to my library! Good find, cybero!

a|x