From classical to quantum mechanics through optics