<commit_before>package com.raizlabs.baseutils;


/**
 * 
 * A class of math utility functions
 * 
 * @author <NAME>
 *
 */
public class Math {
	/**
	 * Returns a linearly interpolated value t percent of the way between the
	 * given start and end values.
	 * @param start The start value
	 * @param end The end value
	 * @param t The percentage along the way to end (0 being the start, 1 being
	 * the end)
	 * @return The linearly interpolated value
	 */
	public static int lerp(int start, int end, float t) {
		return (int) (start + (end - start) * t); 
	}
	
	/**
	 * Returns a linearly interpolated value t percent of the way between the
	 * given start and end values.
	 * @param start The start value
	 * @param end The end value
	 * @param t The percentage along the way to end (0 being the start, 1 being
	 * the end)
	 * @return The linearly interpolated value
	 */
	public static float lerp(float start, float end, float t) {
		return start + (end - start) * t;
	}
	
	/**
	 * Clamps the given value between the two end points.
	 * @param value The value to clamp.
	 * @param min The minimum allowed value.
	 * @param max The maximum allowed value.
	 * @return The clamped value.
	 */
	public static float clamp(float value, float min, float max) {
		return java.lang.Math.min(max, java.lang.Math.max(min, value));
	}
	
	public static float distanceSquared(float x1, float x2, float y1, float y2) {
		return (float) (java.lang.Math.pow(x2 - x1, 2) + java.lang.Math.pow(y2 - y1, 2));
	}
	
	public static float distance(float x1, float x2, float y1, float y2) {
		return (float) java.lang.Math.sqrt(
				java.lang.Math.pow(x2 - x1, 2)  + java.lang.Math.pow(y2 - y1, 2));
	}
}
<commit_msg>Added normalize function to invert lerp.<commit_after>package com.raizlabs.baseutils;


/**
 * 
 * A class of math utility functions
 * 
 * @author <NAME>
 *
 */
public class Math {
	/**
	 * Returns a linearly interpolated value t percent of the way between the
	 * given start and end values.
	 * @param start The start value
	 * @param end The end value
	 * @param t The percentage along the way to end (0 being the start, 1 being
	 * the end)
	 * @return The linearly interpolated value
	 */
	public static int lerp(int start, int end, float t) {
		return (int) (start + (end - start) * t); 
	}
	
	/**
	 * Returns a linearly interpolated value t percent of the way between the
	 * given start and end values.
	 * @param start The start value
	 * @param end The end value
	 * @param t The percentage along the way to end (0 being the start, 1 being
	 * the end)
	 * @return The linearly interpolated value
	 */
	public static float lerp(float start, float end, float t) {
		return start + (end - start) * t;
	}
	
	/**
	 * Returns a value between 0 and 1 which represents how far along the start
	 * and end values the given value is. For example, normalize(0, 100, 50) would
	 * return 0.5 as 50 is halfway between 0 and 100.
	 * <br/><br/>
	 * Note that values larger than end will produce numbers larger than 1 and
	 * values smaller than start will produce negative numbers.
	 * <br/><br/>
	 * Inverse of {@link #lerp(float, float, float)}
	 * @param start The start value
	 * @param end The end value
	 * @param value The value to normalize
	 * @return The value normalized between start and end
	 */
	public static float normalize(float start, float end, float value) {
		return (value - start) / (end - start);
	}
	
	/**
	 * Clamps the given value between the two end points.
	 * @param value The value to clamp.
	 * @param min The minimum allowed value.
	 * @param max The maximum allowed value.
	 * @return The clamped value.
	 */
	public static float clamp(float value, float min, float max) {
		return java.lang.Math.min(max, java.lang.Math.max(min, value));
	}
	
	public static float distanceSquared(float x1, float x2, float y1, float y2) {
		return (float) (java.lang.Math.pow(x2 - x1, 2) + java.lang.Math.pow(y2 - y1, 2));
	}
	
	public static float distance(float x1, float x2, float y1, float y2) {
		return (float) java.lang.Math.sqrt(
				java.lang.Math.pow(x2 - x1, 2)  + java.lang.Math.pow(y2 - y1, 2));
	}
}

{'fraction_non_alphanumeric': 0.10499515033947623, 'fraction_numerical': 0.015761396702230843, 'mean_word_length': 3.108565737051793, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4432334', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1251, 'n_words': 555}