intercept(that) {
		// Thanks to this stack overflow answer by Dan Fox 
		// https://stackoverflow.com/questions/9043805/test-if-two-lines-intersect-javascript-function

		let thisDirection = this.points[1].copy().sub(this.points[0].copy())

		let [thatDx, thatDy] = [that.points[1].x - that.points[0].x, that.points[1].y - that.points[0].y]
		let [thisDx, thisDy] = [this.points[1].x - this.points[0].x, this.points[1].y - this.points[0].y]

		// Calculate the determinant super quick to see if an interception does exist (only 0 if not linearlly independent, which implies the lines are parallel)
		let determinant = thisDx*thatDy - thatDx*thisDy
		if (determinant == 0) {
			return {interception: null, type: 'parallel'}
		}
		// Lambda and Gamma are the constants for the paramaterization of `this` and `that`, respectively
		
		let lambda = ((that.points[1].y - that.points[0].y) * (that.points[1].x - this.points[0].x) + (that.points[0].x - that.points[1].x) * (that.points[1].y-this.points[0].y)) / determinant
		let gamma =  ((this.points[0].y - this.points[1].y) * (that.points[1].x - this.points[0].x) + (this.points[1].x - this.points[0].x) * (that.points[1].y-this.points[0].y)) / determinant

		// This intersection only exists if gamma is between 0 and 1. At 0, the point is `points[0]` and at 1, the point is `points[1]`.
		if (gamma > 1 || gamma < 0) {
			return {interception: null, type: 'parallel'}
		}

		// Are we coincedent anywhere?
		if (lambda == 0) return {interception: this.points[0], type: 'collinear'}
		else if (lambda == 1) return {interception: this.points[1], type: 'collinear'}
		else if (gamma == 0) return {interception: that.points[0], type: 'collinear'}
		else if (gamma == 1) return {interception: that.points[1], type: 'collinear'}

		// Doesn't matter which vector we use now
		return {interception: this.points[0].copy().add(thisDirection.mul(lambda)), type: 'acollinear'}
	}
/**
	 * @name intercept If it exists, returns a point of intersection between two edges. Otherwise, false
	 * @param {Edge} that The other edge to consider
	 * @returns {Point} A new point at the point of intersection, or an existing point if the intersection is coincedent with another point
	 */
@name intercept If it exists, returns a point of intersection between two edges. Otherwise, false
@param {Edge} that The other edge to consider
@returns {Point} A new point at the point of intersection, or an existing point if the intersection is coincedent with another point
@name intercept If it exists returns a point of intersection between two edges . Otherwise false @param { Edge } that The other edge to consider @returns { Point } A new point at the point of intersection or an existing point if the intersection is coincedent with another point
intercept(that) {
		let thisDirection = this.points[1].copy().sub(this.points[0].copy())
		let [thatDx, thatDy] = [that.points[1].x - that.points[0].x, that.points[1].y - that.points[0].y]
		let [thisDx, thisDy] = [this.points[1].x - this.points[0].x, this.points[1].y - this.points[0].y]
		let determinant = thisDx*thatDy - thatDx*thisDy
		if (determinant == 0) {
			return {interception: null, type: 'parallel'}
		}
		let lambda = ((that.points[1].y - that.points[0].y) * (that.points[1].x - this.points[0].x) + (that.points[0].x - that.points[1].x) * (that.points[1].y-this.points[0].y)) / determinant
		let gamma =  ((this.points[0].y - this.points[1].y) * (that.points[1].x - this.points[0].x) + (this.points[1].x - this.points[0].x) * (that.points[1].y-this.points[0].y)) / determinant
		if (gamma > 1 || gamma < 0) {
			return {interception: null, type: 'parallel'}
		}
		if (lambda == 0) return {interception: this.points[0], type: 'collinear'}
		else if (lambda == 1) return {interception: this.points[1], type: 'collinear'}
		else if (gamma == 0) return {interception: that.points[0], type: 'collinear'}
		else if (gamma == 1) return {interception: that.points[1], type: 'collinear'}
		return {interception: this.points[0].copy().add(thisDirection.mul(lambda)), type: 'acollinear'}
	}
intercept ( that ) { let thisDirection = this . points [ 1 ] . copy ( ) . sub ( this . points [ 0 ] . copy ( ) ) let [ thatDx , thatDy ] = [ that . points [ 1 ] . x - that . points [ 0 ] . x , that . points [ 1 ] . y - that . points [ 0 ] . y ] let [ thisDx , thisDy ] = [ this . points [ 1 ] . x - this . points [ 0 ] . x , this . points [ 1 ] . y - this . points [ 0 ] . y ] let determinant = thisDx * thatDy - thatDx * thisDy if ( determinant == 0 ) { return { interception : null , type : 'parallel' } } let lambda = ( ( that . points [ 1 ] . y - that . points [ 0 ] . y ) * ( that . points [ 1 ] . x - this . points [ 0 ] . x ) + ( that . points [ 0 ] . x - that . points [ 1 ] . x ) * ( that . points [ 1 ] . y - this . points [ 0 ] . y ) ) / determinant let gamma = ( ( this . points [ 0 ] . y - this . points [ 1 ] . y ) * ( that . points [ 1 ] . x - this . points [ 0 ] . x ) + ( this . points [ 1 ] . x - this . points [ 0 ] . x ) * ( that . points [ 1 ] . y - this . points [ 0 ] . y ) ) / determinant if ( gamma > 1 || gamma < 0 ) { return { interception : null , type : 'parallel' } } if ( lambda == 0 ) return { interception : this . points [ 0 ] , type : 'collinear' } else if ( lambda == 1 ) return { interception : this . points [ 1 ] , type : 'collinear' } else if ( gamma == 0 ) return { interception : that . points [ 0 ] , type : 'collinear' } else if ( gamma == 1 ) return { interception : that . points [ 1 ] , type : 'collinear' } return { interception : this . points [ 0 ] . copy ( ) . add ( thisDirection . mul ( lambda ) ) , type : 'acollinear' } }
@name intercept If it exists, returns a point of intersection between two edges.
@name intercept If it exists returns a point of intersection between two edges .
// Thanks to this stack overflow answer by Dan Fox  // https://stackoverflow.com/questions/9043805/test-if-two-lines-intersect-javascript-function // Calculate the determinant super quick to see if an interception does exist (only 0 if not linearlly independent, which implies the lines are parallel) // Lambda and Gamma are the constants for the paramaterization of `this` and `that`, respectively // This intersection only exists if gamma is between 0 and 1. At 0, the point is `points[0]` and at 1, the point is `points[1]`. // Are we coincedent anywhere? // Doesn't matter which vector we use now