Earth and Mars are constantly moving, but don’t stay a constant distance apart. Plus, spacecraft don’t travel in a straight line to their destination.