Light does change its direction when it travels from one medium to another, a phenomenon known as refraction. Refraction occurs due to the change in the speed of light as it passes through different substances.
When light passes from one medium to another, such as from air to water or from air to glass, the speed of light changes because it interacts differently with the atoms or molecules in the new medium. This change in speed causes the light wave to bend or deviate from its original path.
The bending of light during refraction can be explained by Snell's law, which states that the angle of incidence (the angle at which the light ray strikes the interface between the two media) and the refractive indices of the two media determine the angle of refraction (the angle at which the light ray bends upon entering the new medium). The refractive index is a measure of how much a substance slows down the speed of light compared to its speed in a vacuum.
The extent to which light bends during refraction depends on the refractive indices of the two media involved. If the refractive index of the second medium is higher than the first, the light ray bends toward the normal (an imaginary line perpendicular to the surface of the interface). Conversely, if the refractive index of the second medium is lower, the light ray bends away from the normal.
It's important to note that light does not change its direction abruptly or instantaneously. Instead, it undergoes continuous bending as it enters and exits different media. This phenomenon is responsible for various optical effects, such as the apparent bending of a pencil in a glass of water or the formation of rainbows in the sky.
However, when light travels through a medium with a uniform refractive index, such as air or vacuum, it continues to travel in a straight line because there are no changes in the medium's properties to cause refraction.