<commit_before>package com.tlear.trise.objects;

import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

public class EnvObject {
	
	public Rectangle rect;
	
	public Vector2 pos;
	
	public final float width;
	public final float height;
	
	public EnvObject(float x, float y, float width, float height) {
		
		pos = new Vector2(x, y);
		
		this.width = width;
		this.height = height;
		
		rect = new Rectangle(x, y, width, height);
	}
}<commit_msg>Intersection functions<commit_after>package com.tlear.trise.objects;

import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.collision.Segment;

public class EnvObject {
	
	public Rectangle rect;
	
	public Vector2 pos;
	
	public final float width;
	public final float height;
	
	public EnvObject(float x, float y, float width, float height) {
		
		pos = new Vector2(x, y);
		
		this.width = width;
		this.height = height;
		
		rect = new Rectangle(x, y, width, height);
	}
	
	/**
	 * Tests whether a point is within or on the object and returns true if it is.
	 * @param p
	 * @return
	 */
	public boolean containsPoint(Vector2 p) {
		if (p.x < pos.x || p.x > pos.x + width) {
			return false;
		}
		if (p.y < pos.y || p.y > pos.y + height) {
			return false;
		}
		return true;
	}
	
	/**
	 * Tests whether a point is within the object and returns true if it is.
	 * @param p
	 * @return
	 */
	public boolean strictlyContainsPoint(Vector2 p) {
		if (p.x <= pos.x || p.x >= pos.x + width) {
			return false;
		}
		if (p.y <= pos.y || p.y >= pos.y + height) {
			return false;
		}
		return true;
	}
	
	public boolean intersectsLine(Vector2 a, Vector2 b) {
		// If either point is in the obstacle then there is an intersection
		if (strictlyContainsPoint(a) || strictlyContainsPoint(b)) {
			return true;
		}
		
		// Test the line segment against the four lines
		if (Intersector.intersectSegments(a, b, pos.cpy(), pos.cpy().add(width, 0), new Vector2())) {
			return true;
		}
		if (Intersector.intersectSegments(a, b, pos.cpy().add(width, 0), pos.cpy().add(width, height), new Vector2())) {
			return true;
		}
		if (Intersector.intersectSegments(a, b, pos.cpy().add(width, height), pos.cpy().add(0, height), new Vector2())) {
			return true;
		}
		if (Intersector.intersectSegments(a, b, pos.cpy().add(0, height), pos.cpy(), new Vector2())) {
			return true;
		}
	
		return false;
	}
}
{'fraction_non_alphanumeric': 0.1323529411764706, 'fraction_numerical': 0.007352941176470588, 'mean_word_length': 3.2739965095986037, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2270836', 'n_tokens_mistral': 949, 'n_tokens_neox': 831, 'n_words': 252}