<commit_before>package geoff.math;

/**
 * ...
 * @author Simon
 */
class Vector2
{

	public var x : Float;
	public var y : Float;
	
	public function new( x : Float = 0, y : Float = 0 ) 
	{
		this.x = x;
		this.y = y;
	}
	
	public function toString() : String 
	{
		return "("+x+","+y+")";
	}
	
	public function setTo(x:Float, y:Float) : Void
	{
		this.x = x;
		this.y = y;
	}
	
	public function distanceSquared() : Float 
	{
		return (x * x) + (y * y);
	}
	
	public function distance() : Float 
	{
		return Math.sqrt( distanceSquared() );
	}
	
	public function normalise() : Vector2 
	{
		var c : Float = Math.abs(x) + Math.abs(y);
		if ( c == 0 ) return new Vector2();
		return new Vector2( x / c, y / c );
	}
	
}<commit_msg>Added vec2 clone and make normalise act in place<commit_after>package geoff.math;

/**
 * ...
 * @author Simon
 */
class Vector2
{

	public var x : Float;
	public var y : Float;
	
	public function new( x : Float = 0, y : Float = 0 ) 
	{
		this.x = x;
		this.y = y;
	}
	
	public function toString() : String 
	{
		return "("+x+","+y+")";
	}
	
	public function setTo(x:Float, y:Float) : Void
	{
		this.x = x;
		this.y = y;
	}
	
	public function distanceSquared() : Float 
	{
		return (x * x) + (y * y);
	}
	
	public function distance() : Float 
	{
		return Math.sqrt( distanceSquared() );
	}
	
	public function normalise( scalar : Float = 1 ) : Vector2 
	{
		var c : Float = Math.abs(x) + Math.abs(y);
		if ( c != 0 ) {
			this.setTo( (x / c) * scalar, ( y / c ) * scalar );
		}
		return this;
	}
	
	public function clone() : Vector2
	{
		return new Vector2( x, y );
	}
	
}
{'fraction_non_alphanumeric': 0.1639549436795995, 'fraction_numerical': 0.010012515644555695, 'mean_word_length': 2.4912663755458517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3072008', 'n_tokens_mistral': 690, 'n_tokens_neox': 613, 'n_words': 179}