Simulated optics experiment/Simulator: Difference between revisions

Content added Content deleted
(Added "coroutines".)
(Added an etc.)
Line 27: Line 27:
* On the right, the first angle is 22.5° and the second is 67.5°.
* On the right, the first angle is 22.5° and the second is 67.5°.


The simulation is run by having the light source emit some number of pulses and letting the other devices do their work. How you arrange this to work is up to you. The [[#Python|Python]] example, for instance, runs each device as a separate process, connected to each other by queues. But you can instead have, for instance, an event loop, coroutines, or even just ordinary, procedural calculation of the numbers. (The last method is simplest, and perfectly correct. However, simulating the devices as independent processes, objects in an event loop, etc., has a psychological advantage, which may be important if you are trying to convince someone of your point.)
The simulation is run by having the light source emit some number of pulses and letting the other devices do their work. How you arrange this to work is up to you. The [[#Python|Python]] example, for instance, runs each device as a separate process, connected to each other by queues. But you can instead have, for instance, an event loop, coroutines, etc.--or even just ordinary, procedural calculation of the numbers. (The last method is simplest, and perfectly correct. However, simulating the devices as independent processes, objects in an event loop, etc., has a psychological advantage, which may be important if you are trying to convince someone of your point.)


The program must output its "raw data" results in the format shown here by example:
The program must output its "raw data" results in the format shown here by example: