How to simulate ray of light reflection

Hi

Can I use Box2d to simulate ray of light and its reflection from the mirror. The ray should has some length and when it reflected by the mirror should looks something like shown on the first attached file. On the next simulation step the ray should looks like show on the second attached file.

Horizontal black line is a mirror surface. Red line is the ray. The ray is moving from left to right then reflected the mirror and start moving right to left.

thx
alex
This kind of problem is so painfully easy that a physics engine is overkill and overcomplicating the problem. 😆
I understand that it's probably not the best Box2D usage and it's better to do that manually. But if it would be easy to do that reflection using box2d it unify my app architecture and there would be no need for custom solution.

I am currently thinking about chain of perfectly elastic balls. Not sure will it perfectly simulate ray reflection 🙂

alex
Are you sure your problem is not only a rendering problem ? A ray of light is fast as light. What do you expect out of the physical engine ? Even with a chain of balls, Box2D will not tell you where to place the balls, so you'd still have to calculate the ray trajectory yourself.

You could make a single ball bounce, but I'm not sure Box2D guarantees perfect reflection-like bouncing, and you will have to perform several steps simulation to get the trajectory (I guess that kills your unification of architecture).

Original thread: https://box2d.org/forum/viewtopic.php?t=4853