# Process the trajectory in the top molecule, and store the distance # moved by each particle relative to the previous frame in the user field # Justin Gullingsrud # justinrocks@gmail.com # 21 August 2005 proc colorBySpeed { } { set n [molinfo top get numframes] set all [atomselect top all] set oldx [$all get x] set oldy [$all get y] set oldz [$all get z] for { set i 1 } { $i < $n } { incr i } { $all frame $i set x [$all get x] set y [$all get y] set z [$all get z] set delta [list] foreach dx [vecsub $x $oldx] dy [vecsub $y $oldy] dz [vecsub $z $oldz] { lappend delta [expr {sqrt($dx*$dx + $dy*$dy + $dz*$dz)}] } $all set user $delta set oldx $x set oldy $y set oldz $z } }