computes closest uv pair with [w]