how light beam gets refracted in denser or rarer medium