## 2 System Design Principles
### Principles of Optical Experiments  
In reference to the teaching objectives of the \"University Physics Laboratory\" course, the virtual simulation system is designed to encompass experimental aspects of optical physics, including spectrophotometer adjustment, non-perpendicular incident grating diffraction, and equal-inclination grating diffraction. The principles of these experiments are outlined as follows. Initially, when light is incident perpendicularly on a grating, according to the diffraction theory of gratings, the positions of the bright fringes in the diffraction spectrum are determined by the following equation:  
\[dsin\varphi_{k}=\pm k\lambda \tag{1}\]  
where \(d\) represents the grating constant, \(\lambda\) is the wavelength of the incident light, \(k\) denotes the order of the bright fringe (spectral line), and \(\varphi_{k}\) signifies the diffraction angle of the \(k\)-order bright fringe. If the incident light is polychromatic, different wavelengths will result in distinct diffraction angles \(\varphi_{k}\), leading to the dispersion of the polychromatic light. At the central point (\(k=0\), \(\varphi_{k}=0\)), all colors overlap to form the central bright fringe. Symmetrically distributed on either side of the central bright fringe (\(k=0\)) are spectral lines for \(k=0,\ 1,\ 2,\ 3,\ \cdots\). These spectral lines are arranged in order of increasing wavelength, forming a spectrum known as the grating spectrum, as illustrated in Figure 2a. Subsequently, when the grating plane is rotated from a state of perpendicular incidence with an angle \(i\) (where \(i\) is the angle of parallel light incidence), the diffraction angle is defined as the angle between the diffracted light and the 0 th-order spectrum. According to grating diffraction theory, the formula for non-perpendicular incidence is as follows:  
\[dsin(\varphi_{k}-i)+dsini=\pm k\lambda,(k=0,1,2,\ldots) \tag{2}\]where \(d\) represents the grating constant, \(\lambda\) is the wavelength of the incident light, \(k\) denotes the order of the bright fringe (spectral line), \(\varphi_{k}\) signifies the diffraction angle of the \(k\)-order bright fringe, and \(i\) is the angle of incidence of the light ray. Finally, when the incident light and diffracted light are on the same side, for green light with a known wavelength \(\lambda\) incident at an angle \(i\) on the grating, satisfying Formula (2), it is evident that the diffraction angle \(\varphi_{k}\) varies with the change in \(i\). Through mathematical methods, it is not difficult to prove that when \(\varphi_{k}=2i\), \(\varphi_{k}\) has a minimum value, known as the minimum diffraction angle (\(\varphi_{min}\)). Importantly, the minimum diffraction angle occurs only when the incident and diffracted light are on the same side. Therefore, substituting \(\varphi_{min}\) into the formula,  
\[d=\frac{k\lambda}{2 sin(\frac{\varphi_{min}}{2})},(k=0,1,2,\ldots) \tag{3}\]  
where \(\lambda\) is the wavelength of green light. By measuring \(\varphi_{min}\), the grating constant \(d\) can be determined. When implementing the virtual simulation system, considering the issue of performance optimization, the simulation of grating diffraction is displayed in the UI window at the bottom left corner. The display function of this window is equivalent to the observation function of the eyepiece in the real-world spectrometer. The simulation method presents diffraction spectra in different colors as images. When adjusting the experimental components, the position, rotation, transparency, width, and narrowness of the images in the UI window are adjusted by the formulas and algorithms based on the physical principles, achieving the simulation of diffraction patterns. When investigating the physical mechanism behind the virtual circular diffraction pattern generation, the green electronic screen allows the selection of grating types (600-line grating, 300-line grating) and laser colors (green laser 532 nm, violet laser 405 nm, red laser 666 nm).