main/src/georegression/fitting/line/FitLine_I32.java
public static LinePolar2D_F32 polar(List<Point2D_I32> points , int start , int length , LinePolar2D_F32 ret ) {
		if( ret == null )
			ret = new LinePolar2D_F32();

		int sumX = 0;
		int sumY = 0;

		final int N = length;
		for( int i = 0; i < N; i++ ) {
			Point2D_I32 p = points.get(start+i);
			sumX += p.x;
			sumY += p.y;
		}
		float meanX = sumX / (float)N;
		float meanY = sumY / (float)N;

		float top = 0;
		float bottom = 0;

		for( int i = 0; i < N; i++ ) {
			Point2D_I32 p = points.get(start+i);
			float dx = meanX - p.x;
			float dy = meanY - p.y;

			top += dx*dy;
			bottom += dy*dy - dx*dx;
		}

		ret.angle = (float)Math.atan2(-2.0f*top , bottom)/2.0f;
		ret.distance = (float)( meanX*Math.cos(ret.angle) + meanY*Math.sin(ret.angle));

		return ret;
	}
public static LinePolar2D_F32 polar(List<Point2D_I32> points , int start , int length , LinePolar2D_F32 ret ) {
		if( ret == null )
			ret = new LinePolar2D_F32();

		int sumX = 0;
		int sumY = 0;

		final int N = length;
		for( int i = 0; i < N; i++ ) {
			Point2D_I32 p = points.get(start+i);
			sumX += p.x;
			sumY += p.y;
		}
		float meanX = sumX / (float)N;
		float meanY = sumY / (float)N;

		float top = 0;
		float bottom = 0;

		for( int i = 0; i < N; i++ ) {
			Point2D_I32 p = points.get(start+i);
			float dx = meanX - p.x;
			float dy = meanY - p.y;

			top += dx*dy;
			bottom += dy*dy - dx*dx;
		}

		ret.angle = (float)Math.atan2(-2.0f*top , bottom)/2.0f;
		ret.distance = (float)( meanX*Math.cos(ret.angle) + meanY*Math.sin(ret.angle));

		return ret;
	}
<p>
Computes the unweighted best fit line to the set of points using the polar line equation. The solution
is optimal in the Euclidean sense, see [1] for more details.
</p>

<p>
[1] K. Arras, R. Siegwart, "Feature Extraction and Scene Interpretation for Map-Based Navigation
and Map Building" Proc. SPIE, Mobile Robotics XIII, Vol. 3210, 1997
</p>

@param points Set of points on the line.
@param start First index in the list
@param length number of variables used in the list
@param ret Storage for the line.  If null a new line will be declared.
@return Best fit line