     tcoll: tcoll  #when nearest approach occurs
   }
 
+#Calculate time, when 2 spaceship approach to the specified distance.
 approachParameters = (pos0, delta0, pos1, delta1, approachDistance) ->
-  #Calculate time, when 2 spaceship approach to the specified distance.
   [dx, dy, dt] = vecDiff pos0, pos1
   [vx0, vy0, p0] = delta0
   [vx1, vy1, p1] = delta1

#    collision::bool true if collision
#    timeStart::int first generation, where interaction has started
#    products::[ ProductDesc ]  list of collision products (patterns with their positions and classification
doCollision = (rule, p1, v1, p2, v2, offset, startDist = 30, collisionTreshold=20)->
  waitForCollision = v1[2] + v2[2] #sum of periods
  params = collisionParameters [0,0,0], v1, offset, v2  
  ap = approachParameters [0,0,0], v1, offset, v2, startDist
  collision = {collision:false}
  if not ap.approach
    #console.log "#### No approach, nearest approach: #{params.dist}"

  collision.products = finishCollision rule, coll.field, coll.time
  return collision

#Simulate 2 patterns until they collide.
# Return first oment of time, when patterns started interacting.
simulateUntilCollision = (rule, fld1, fld2, time, timeGiveUp) ->
  fld  = fld1.concat fld2  
  while time < timeGiveUp
