def fit(v, oldmin, oldmax, newmin=0.0, newmax=1.0):
	"""
	Just a standard math fit/remap function 

		number v 		- initial value from old range 
		number oldmin 	- old range min value 
		number oldmax 	- old range max value 
		number newmin 	- new range min value 
		number newmax 	- new range max value  

	Example:

		fit(50, 0, 100, 0.0, 1.0)
		# 0.5

	"""
	scale = (float(v) - oldmin) / (oldmax - oldmin) 
	new_range = scale * (newmax - newmin)
	if newmin < newmax: 
		return newmin + new_range
	else: 
		return newmin - new_range