module.exports = "//\n//\n// FIT\n//\n//\nfloat fit(float val, float srcMin, float srcMax, float destMin, float destMax){\n	float src_range = srcMax - srcMin;\n	float dest_range = destMax - destMin;\n\n	float r = (val - srcMin) / src_range;\n	return (r * dest_range) + destMin;\n}\nvec2 fit(vec2 val, vec2 srcMin, vec2 srcMax, vec2 destMin, vec2 destMax){\n	return vec2(\n		fit(val.x, srcMin.x, srcMax.x, destMin.x, destMax.x),\n		fit(val.y, srcMin.y, srcMax.y, destMin.y, destMax.y)\n	);\n}\nvec3 fit(vec3 val, vec3 srcMin, vec3 srcMax, vec3 destMin, vec3 destMax){\n	return vec3(\n		fit(val.x, srcMin.x, srcMax.x, destMin.x, destMax.x),\n		fit(val.y, srcMin.y, srcMax.y, destMin.y, destMax.y),\n		fit(val.z, srcMin.z, srcMax.z, destMin.z, destMax.z)\n	);\n}\nvec4 fit(vec4 val, vec4 srcMin, vec4 srcMax, vec4 destMin, vec4 destMax){\n	return vec4(\n		fit(val.x, srcMin.x, srcMax.x, destMin.x, destMax.x),\n		fit(val.y, srcMin.y, srcMax.y, destMin.y, destMax.y),\n		fit(val.z, srcMin.z, srcMax.z, destMin.z, destMax.z),\n		fit(val.w, srcMin.w, srcMax.w, destMin.w, destMax.w)\n	);\n}\n\n//\n//\n// FIT TO 01\n// fits the range [srcMin, srcMax] to [0, 1]\n//\nfloat fitTo01(float val, float srcMin, float srcMax){\n	float size = srcMax - srcMin;\n	return (val - srcMin) / size;\n}\nvec2 fitTo01(vec2 val, vec2 srcMin, vec2 srcMax){\n	return vec2(\n		fitTo01(val.x, srcMin.x, srcMax.x),\n		fitTo01(val.y, srcMin.y, srcMax.y)\n	);\n}\nvec3 fitTo01(vec3 val, vec3 srcMin, vec3 srcMax){\n	return vec3(\n		fitTo01(val.x, srcMin.x, srcMax.x),\n		fitTo01(val.y, srcMin.y, srcMax.y),\n		fitTo01(val.z, srcMin.z, srcMax.z)\n	);\n}\nvec4 fitTo01(vec4 val, vec4 srcMin, vec4 srcMax){\n	return vec4(\n		fitTo01(val.x, srcMin.x, srcMax.x),\n		fitTo01(val.y, srcMin.y, srcMax.y),\n		fitTo01(val.z, srcMin.z, srcMax.z),\n		fitTo01(val.w, srcMin.w, srcMax.w)\n	);\n}\n\n//\n//\n// FIT FROM 01\n// fits the range [0, 1] to [destMin, destMax]\n//\nfloat fitFrom01(float val, float destMin, float destMax){\n	return fit(val, 0.0, 1.0, destMin, destMax);\n}\nvec2 fitFrom01(vec2 val, vec2 srcMin, vec2 srcMax){\n	return vec2(\n		fitFrom01(val.x, srcMin.x, srcMax.x),\n		fitFrom01(val.y, srcMin.y, srcMax.y)\n	);\n}\nvec3 fitFrom01(vec3 val, vec3 srcMin, vec3 srcMax){\n	return vec3(\n		fitFrom01(val.x, srcMin.x, srcMax.x),\n		fitFrom01(val.y, srcMin.y, srcMax.y),\n		fitFrom01(val.z, srcMin.z, srcMax.z)\n	);\n}\nvec4 fitFrom01(vec4 val, vec4 srcMin, vec4 srcMax){\n	return vec4(\n		fitFrom01(val.x, srcMin.x, srcMax.x),\n		fitFrom01(val.y, srcMin.y, srcMax.y),\n		fitFrom01(val.z, srcMin.z, srcMax.z),\n		fitFrom01(val.w, srcMin.w, srcMax.w)\n	);\n}\n\n//\n//\n// FIT FROM 01 TO VARIANCE\n// fits the range [0, 1] to [center - variance, center + variance]\n//\nfloat fitFrom01ToVariance(float val, float center, float variance){\n	return fitFrom01(val, center - variance, center + variance);\n}\nvec2 fitFrom01ToVariance(vec2 val, vec2 center, vec2 variance){\n	return vec2(\n		fitFrom01ToVariance(val.x, center.x, variance.x),\n		fitFrom01ToVariance(val.y, center.y, variance.y)\n	);\n}\nvec3 fitFrom01ToVariance(vec3 val, vec3 center, vec3 variance){\n	return vec3(\n		fitFrom01ToVariance(val.x, center.x, variance.x),\n		fitFrom01ToVariance(val.y, center.y, variance.y),\n		fitFrom01ToVariance(val.z, center.z, variance.z)\n	);\n}\nvec4 fitFrom01ToVariance(vec4 val, vec4 center, vec4 variance){\n	return vec4(\n		fitFrom01ToVariance(val.x, center.x, variance.x),\n		fitFrom01ToVariance(val.y, center.y, variance.y),\n		fitFrom01ToVariance(val.z, center.z, variance.z),\n		fitFrom01ToVariance(val.w, center.w, variance.w)\n	);\n}";
