<commit_before>package h3d.col;

class Seg {
	
	public var p1 : Vector;
	public var p2 : Vector;
	
	public inline function new( p1 : Vector, p2 : Vector ) {
		this.p1 = p1;
		this.p2 = p2;
	}
	
	public inline function distanceSq( p : Vector ) {
		var d = p1.distanceSq(p2);
		return if( d == 0 )
			p.distanceSq(p1);
		else {
			var t = p.sub(p1).dot3(p2.sub(p1)) / d;
			if( t < 0 )
				p.distanceSq(p1);
			else if( t > 1 )
				p.distanceSq(p2);
			else
				p.distanceSq(new Vector(p.x + t * (p2.x - p1.x), p.y + t * (p2.y - p1.y)));
		}
	}
	
	public inline function distance( p : Vector ) {
		return FMath.sqrt(distanceSq(p));
	}
	
}<commit_msg>fix, do not handle 0 length<commit_after>package h3d.col;

class Seg {
	
	public var p1 : Vector;
	public var p2 : Vector;
	public var lenSq : Float;
	
	public inline function new( p1 : Vector, p2 : Vector ) {
		this.p1 = p1;
		this.p2 = p2;
		lenSq = p1.distanceSq(p2);
	}
	
	public inline function distanceSq( p : Vector ) {
		var t = p.sub(p1).dot3(p2.sub(p1)) / lenSq;
		return if( t < 0 )
			p.distanceSq(p1);
		else if( t > 1 ) {
			p.distanceSq(p2);
		} else
			p.distanceSq(new Vector(p1.x + t * (p2.x - p1.x), p1.y + t * (p2.y - p1.y)));
	}
	
	public inline function distance( p : Vector ) {
		return FMath.sqrt(distanceSq(p));
	}
	
}
{'fraction_non_alphanumeric': 0.15724244771494966, 'fraction_numerical': 0.039504260263361735, 'mean_word_length': 2.598885793871866, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4175336', 'n_tokens_mistral': 628, 'n_tokens_neox': 562, 'n_words': 143}