A ray diagram is a visual representation used in optics to depict the path that light rays take as they travel through different media and interact with optical elements. This method simplifies complex interactions by using straight lines to represent the direction of light, making it easier to understand how images are formed by lenses or mirrors, and is essential in analyzing phenomena like total internal reflection.