def centerOfMass(positions, weights):
  """
  Calculate the center of mass of a set of weighted positions.

  Args:
    positions: A list of (x,y,z) position tuples
    weights: A list of position weights 
  Return:
    A tuple of floats representing the coordinates of the center of mass.
  """
  tot_weight = sum(weights) 
  assert tot_weight != 0
  zipped = zip(positions, weights)
  [x, y, z] = [0.0, 0.0, 0.0]
  for (pos, weight) in zipped:
    x += pos[0] * weight 
    y += pos[1] * weight 
    z += pos[2] * weight 
  return tuple(map(lambda k: k / tot_weight, [x,y,z]))