daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. constant c_inverse_squares
  2. constant c_springs
  3. constant c_gravity
  4. constant c_dampening
  5.  
  6. foreach (node n1)
  7.   foreach (node n2)
  8.    
  9.     force = (0, 0)
  10.    
  11.     if (n1 != n2)
  12.    
  13.       force += inverse_squares (n1, n2)
  14.       force += gravity (n1, n2)
  15.      
  16.       if (n1 isconnectedto n2)      
  17.         force += hookelaw (n1, n2)      
  18.       endif
  19.    
  20.     endif
  21.    
  22.     n1.velocity += force
  23.     n1.velocity *= c_dampening
  24.    
  25.   end
  26. end
  27. for nodes { position += node.velocity}
RAW Paste Data
Top