Creating an interactive physics simulation
This recipe will show us how powerful SVG can be as an educational tool. We will create a drawing of a simple Monochromator optical device, consisting of a light source and a prism, and use a script to generate SVG light beams that simulate the light refraction according to the laws of physics. The drawing will contain widgets that change various physics parameters that influence the "experiment" results, and the script will ensure that the behavior will be realistic.
Although most of the work for this recipe is contained in the script, it is still a useful example of how Inkscape and SVG can be very flexible tools in various simulations and interactive illustrations.
How to do it...
The following steps demonstrate the creation of an interactive physics simulation:
1. Open Document Properties (Shift + Ctrl + D) and change the Background: to opaque black by moving the L slider to the left and A to the right. The document background will turn black.
2...