Launch windows are calculated using orbital mechanics, which is the study of the motion of bodies in space under the influence of gravity and other forces. Orbital mechanics can help determine the optimal launch angle, velocity, and direction for a spacecraft to reach a desired orbit or destination. Orbital mechanics can also help estimate the effects of perturbations, such as atmospheric drag, solar radiation pressure, and gravitational interactions, on the spacecraft trajectory and orbit.
To calculate launch windows, you need to know the orbital elements of the Earth and the target body, such as their semi-major axes, eccentricities, inclinations, longitudes of ascending nodes, arguments of periapsis, and mean anomalies. You also need to know the launch site coordinates, the desired orbit or destination parameters, and the launch vehicle characteristics. Using these inputs, you can use various methods and tools, such as the Hohmann transfer, the patched conic approximation, the Lambert problem, and the porkchop plot, to find the possible launch windows and select the best one.