Use fabs() instead of abs() in unit_vector_constrain.