Accurate predictive model for twisted nematic liquid crystal devices : application for generating programmable apodizers and Fresnel lenses