The generalized laws of refraction and reflection