Cartoon of a generic beamline 

This animation shows generic components found at a synchrotron beamline. These include (in order of travelling with the photons): ID source, blade x-ray BPM, beam-defining aperture, high-pass filter/window, beam-defining slits, a collimating toroidal mirror, a double-crystal monochromator, a focussing toroidal mirror, a pinhole, a Fresnel zone plate, an I0 monitor, a sample, and a detector. Any given actual beamline may looks substantially different, with different order of components, component variations, and/or missing elements. 

The undulator undergoes four gap cycles in the animation, as the energy increases and jumps from one harmonic to the next (starting at the third, then moving to the fifth, seventh, and ninth), which can be seen in the undulator spectrum plotted above the undulator. Thanks go to Thomas Schmidt at PSI for providing the spectrum (downloadable here). As the energy increases, the Bragg angle of the DCM decreases accordingly, while the goniometer stage of the second crystal also moves to ensure a fixed exit height of the x-rays. The beam is refocused onto a pinhole and then a FZP, which provides a microfocus on the rotating crystal sample. A diffraction pattern is recorded on the area detector. Needless to say, it is uncommon for diffraction data to be recorded while scanning the photon energy, but it looked too cute for me to leave this out… Suggestions for improvements or changes/additions are most welcome. 

The code is extremely long, though admittedly a good third of this is taken up with comments. It uses two matlab functions: mArrow3.m to generate fancy 3D arrows, which I downloaded from MathWorks File Exchange, and for which I credit Georg Stillfried; and a modified version of plotcube.m (credit Olivier from MathWorks), where I added the possibility to remove the edge lines by setting their alpha value to 0. Unfortunately, I have not been able to rotate the cuboid output of this function. If anyone knows how to modify it to do this, it would make this function extremely useful!