main/src/georegression/metric/Intersection2D_F64.java
public static Point2D_F64 intersection( Point2D_F64 lineA0 , Point2D_F64 lineA1 ,
											Point2D_F64 lineB0 , Point2D_F64 lineB1 ,
											Point2D_F64 output )
	{
		if( output == null )
			output = new Point2D_F64();

		double slopeAx = lineA1.x - lineA0.x;
		double slopeAy = lineA1.y - lineA0.y;
		double slopeBx = lineB1.x - lineB0.x;
		double slopeBy = lineB1.y - lineB0.y;

		double top = slopeAy * ( lineB0.x - lineA0.x ) + slopeAx * (lineA0.y - lineB0.y );
		double bottom = slopeAx * slopeBy - slopeAy * slopeBx;

		if( bottom == 0 )
			return null;
		double t = top / bottom;

		output.x = lineB0.x + t*slopeBx;
		output.y = lineB0.y + t*slopeBy;

		return output;
	}
public static Point2D_F64 intersection( Point2D_F64 lineA0 , Point2D_F64 lineA1 ,
											Point2D_F64 lineB0 , Point2D_F64 lineB1 ,
											Point2D_F64 output )
	{
		if( output == null )
			output = new Point2D_F64();

		double slopeAx = lineA1.x - lineA0.x;
		double slopeAy = lineA1.y - lineA0.y;
		double slopeBx = lineB1.x - lineB0.x;
		double slopeBy = lineB1.y - lineB0.y;

		double top = slopeAy * ( lineB0.x - lineA0.x ) + slopeAx * (lineA0.y - lineB0.y );
		double bottom = slopeAx * slopeBy - slopeAy * slopeBx;

		if( bottom == 0 )
			return null;
		double t = top / bottom;

		output.x = lineB0.x + t*slopeBx;
		output.y = lineB0.y + t*slopeBy;

		return output;
	}
public static Point2D_F64 intersection ( Point2D_F64 lineA0 , Point2D_F64 lineA1 , Point2D_F64 lineB0 , Point2D_F64 lineB1 , Point2D_F64 output ) { if ( output == null ) output = new Point2D_F64 ( ) ; double slopeAx = lineA1 . x - lineA0 . x ; double slopeAy = lineA1 . y - lineA0 . y ; double slopeBx = lineB1 . x - lineB0 . x ; double slopeBy = lineB1 . y - lineB0 . y ; double top = slopeAy * ( lineB0 . x - lineA0 . x ) + slopeAx * ( lineA0 . y - lineB0 . y ) ; double bottom = slopeAx * slopeBy - slopeAy * slopeBx ; if ( bottom == 0 ) return null ; double t = top / bottom ; output . x = lineB0 . x + t * slopeBx ; output . y = lineB0 . y + t * slopeBy ; return output ; }
Finds the point of intersection between the two lines defined by the set sets of points passed in.
@param lineA0 Point on line A
@param lineA1 Point on line A
@param lineB0 Point on line B
@param lineB1 Point on line B
@param output (Optional) storage for point of intersection
@return Point of intersection or null if the lines are parallel
Finds the point of intersection between the two lines defined by the set sets of points passed in .