code: private void closestFarthestPoints(LineSegment2D_F32 a, LineSegment2D_F32 b)
  	{
  		dist[0] = a.a.distance2(b.a);
  		dist[1] = a.a.distance2(b.b);
  		dist[2] = a.b.distance2(b.a);
  		dist[3] = a.b.distance2(b.b);
  
  		// find the two points which are closest together and save which ones those are
  		// for future reference
  		farthestIndex = 0;
  		float closest = dist[0];
  		float farthest = dist[0];
  		for( int i = 1; i < 4; i++ ) {
  			float d = dist[i];
  			if( d < closest ) {
  				closest = d;
  				closestIndex = i;
  			}
  			if( d > farthest ) {
  				farthest = d;
  				farthestIndex = i;
  			}
  		}
  	}
docs: Finds the points on each line which are closest and farthest away from each other.