 
 ! F = ma
 
-: calc-acceleration ( node -- vec ) [ node-force ] [ node-mass ] bi v/n ;
+: calc-acceleration ( node -- vec ) [ force>> ] [ mass>> ] bi v/n ;
 
 : new-vel ( node -- vel )
   [ vel>> ] [ calc-acceleration time-slice> v*n ] bi v+ ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: relative-velocity-a ( spring -- vel )
  [ spring-node-a vel>> ] [ spring-node-b vel>> ] bi v- ;

: unit-vec-b->a ( spring -- vec )
  [ spring-node-a pos>> ] [ spring-node-b pos>> ] bi v- ;

: relative-velocity-along-spring-a ( spring -- vel )
  [ relative-velocity-a ] [ unit-vec-b->a ] bi vector-projection ;

: damping-force-a ( spring -- vec )
  [ relative-velocity-along-spring-a ] [ spring-damp ] bi v*n vneg ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: relative-velocity-b ( spring -- vel )
  [ spring-node-b vel>> ] [ spring-node-a vel>> ] bi v- ;

: unit-vec-a->b ( spring -- vec )
  [ spring-node-b pos>> ] [ spring-node-a pos>> ] bi v- ;

: relative-velocity-along-spring-b ( spring -- vel )
  [ relative-velocity-b ] [ unit-vec-a->b ] bi vector-projection ;

: damping-force-b ( spring -- vec )
  [ relative-velocity-along-spring-b ] [ spring-damp ] bi v*n vneg ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: act-on-nodes-damping ( spring -- )
  dup
  [ spring-node-a ] [ damping-force-a ] bi apply-force
  [ spring-node-b ] [ damping-force-b ] bi apply-force ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


! node
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

TUPLE: node < vel mass elas force ;

C: <node> node

: node-vel ( node -- vel ) vel>> ;

