code: function tvi (adaptation_luminance) {
  	// returns the threshold luminance given the adaptation luminance
  	// units are candelas per meter squared
  	var log_a = log10(adaptation_luminance);
  
  	var r;
  	if (log_a < -3.94) {
  		r = -2.86;
  	} else if (log_a < -1.44) {
  		r = Math.pow(0.405 * log_a + 1.6, 2.18) - 2.86;
  	} else if (log_a < -0.0184) {
  		r = log_a - 0.395;
  	} else if (log_a < 1.9) {
  		r = Math.pow(0.249 * log_a + 0.65, 2.7) - 0.72;
  	} else {
  		r = log_a - 1.255;
  	}
  
  	return Math.pow(10.0, r);
  }
docs: /*
  Given the adaptation luminance, this function returns the
  threshold of visibility in cd per m^2
  TVI means Threshold vs Intensity function
  This version comes from Ward Larson Siggraph 1997