[PD] elasticity algorithm

siggmuss siggmus at fastmail.fm
Wed Apr 14 10:33:51 CEST 2004


Look:
loop
    distance = targetPos - currentPos
    currentPos = currentPos + distance * 0.1
end loop



this is an algorithm  to make some friction ...is similar to the "ping
pong algorithm"... 0.1 is the damping 
value(it could be between 0 and 0.99)....if no further force accelerates
the particle, slowly the velocity will decrease and finally become 0
(velocity gets replaced by the distance value between the current
position and the end position)

well.......instead of applying friction to velocity u can apply to
acceleration to get some elasticity effects:
depending on how far our particle is from its final anchor point, it will
accelerate more . The close it gets, it will accelerate less. But since
it has aquired a certain linear momentum, it will actualy not stop at the
target, but shoot over it and continue its trajectory. the further it
gets away, the more increases the negative acceleration until the
particle stops and turns towards the target again... in lingo is
something like this:

velocityx= velocityx *dampin+(the clickloc[1]-sprite(1).loch)
  velocityy= velocityy *dampin+(the clickloc[2]-sprite(1).locv)
  
  sprite(1).loch =sprite(1).loch+velocityx
  sprite(1).locv =sprite(1).locv+velocityy





i send elasticity (numbers) from lingo to pd via midi or osc and i use
them to control some sound parameters
like pannings..... well thats all bye








-- 
http://www.fastmail.fm - Or how I learned to stop worrying and
                          love email again




More information about the Pd-list mailing list