From wave theory to ray optics