# Model-Based Design and Simulation of Paraxial Ray Optics Systems
## 1 Introduction  
A model-based design allows describing complex, multi-domain systems as interconnected modules that represent components of the overall project. In a mechatronics concept, mechanical, electrical, and magnetic subsystems communicate through input/output signals from sensors, actuators, control loops, and artificial intelligence. This approach simplifies the model identification and evaluation, and can be used to validate the system response to several inputs [1]. Simulation is also beneficial to the e-learning experience: virtual labs provide a feasible environment for testing analytical projects, besides reducing the time and infrastructure costs demanded by physical experiments [2; 3]. Regarding the development of optical systems, typical examples of multi-domain implementations comprise beam monochromators [4], auto-focusing systems for imaging and disk readers [5], 3D scanners [6], and optoelectronic transducers [7]. Apart from wave, electromagnetic, and quantum optics approaches, geometrical optics is a straightforward and simpler way for tracing the light path in terms of successive transmission, reflection, and refraction, with notable applications in imaging systems [8], illumination [9], optometry [10], and computer graphics [11]. Although a variety of commercial and open-source software for ray tracing is currently available [12; 13; 14], integrating multiple physical domains into a unique simulation environment is still a challenge, especially regarding implementations in optomechatronics, wherein the optical system must be updated in response to the stimuli from the electromechanical module, while the information provided by the optical setup is applied as a feedback to the control loop. Moreover, thecomputer program should be accessible and easy-to-use, present a graphical programming interface that resembles the physical placement of components, and communicate with third-party applications. In this sense, using MATLAB (Mathworks) or LabVIEW (National Instruments) is a convenient way to adapt custom-made ray optics functions to the available multi-domain models, with perspectives for real-time and hardware-in-loop implementations. For instance, script-based MATLAB libraries were proposed to evaluate paraxial optical systems [15; 16], whereas in [17], the Simulink environment was applied to compute the mechanical response. At the same time, light trajectory is displayed using CODE V (Synopsys). Concurrent calculations in the optical, electrical, and mechanical domains were also carried out by Simulink for designing micro-scale devices [18] and telescopes [8], the latter communicates with external ray tracing software. Furthermore, control and tracing were conceived with LabVIEW to operate an instrumented testbed for aerospace applications [19]. Alternatively, one may use the Delano diagrams to evaluate power density and depict ray tracing in a compact notation that contains the comprehensive information provided by Gaussian optics without showing the explicit placement of optical components [20; 21]. Despite the available works, a consolidated modeling and visualization environment for optical and multi-physical design is still required to fulfill the optical engineering design and educational purposes. This paper proposes using MATLAB Simulink to develop model-based 2D paraxial optical and optomechatronics systems in unique software. Ray tracing is performed using the optics transfer matrices, wherein the position and orientation of light rays vary over time according to the simulation results for dynamically updating the tracing profile. Moreover, programming is facilitated by graphical language since the optical components are presented as functional blocks, wherein the interface with mechanical and electrical domains is settled with appropriate transducers.