gt: 		List<java.lang.Double> thetas = new Vector<>();
context: /*
   * Manipulate and analyse DNA fibers data
   * This plugin extracts and unfold the DNA fibers selected by a curve ROI
   * Copyright (C) 2016  Julien Pontabry (Helmholtz IES)
  
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
  
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
  
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  package coordinates;
  
  import java.awt.geom.Point2D;
  import java.util.List;
  import java.util.Vector;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  
  import ij.IJ;
  import ij.ImagePlus;
  import ij.gui.Roi;
  import ij.process.ImageProcessor;
  
  /**
   * Define the a point in image space.
   * 
   * The origin in at top-left of the image.
   * 
   * @author julien.pontabry
   */
  public class ImagePoint extends Point2D {
  	/** The X coordinate of image. */
  	public int x;
  	
  	/** The Y coordinate of image. */
  	public int y;
  	
  	/** Pre-computed constant (useful in particular for local model estimation). */
  	protected static final double PIover2 = Math.PI/2.;
  	
  	/**
  	 * Default constructor.
  	 * 
  	 * Gives the origin point.
  	 */
  	public ImagePoint(){
  		// ---
  	}
  	
  	/**
  	 * Constructor.
  	 * @param x Input X coordinate.
  	 * @param y Input Y coordinate.
  	 */
  	public ImagePoint(int x, int y) {
  		this.x = x;
  		this.y = y;
  	}
  	
  	/**
  	 * Copy constructor.
  	 * @param p Input point to copy.
  	 */
  	public ImagePoint(ImagePoint p) {
  		this.x = p.x;
  		this.y = p.y;
  	}
  	
  	/**
  	 * @see java.awt.geom.Point2D#getX()
  	 */
  	@Override
  	public double getX() {
  		return this.x;
  	}
  
  	/**
  	 * @see java.awt.geom.Point2D#getY()
  	 */
  	@Override
  	public double getY() {
  		return this.y;
  	}
  
  	/**
  	 * @see java.awt.geom.Point2D#setLocation(double, double)
  	 */
  	@Override
  	public void setLocation(double x, double y) {
  		this.x = (int)Math.round(x);
  		this.y = (int)Math.round(y);
  	}
  
  	/**
  	 * Integer override of setLocation method.
  	 * @param x The new integer X-coordinate of the point.
  	 * @param y The new integer Y-coordinate of the point.
  	 * @see java.awt.geom.Point2D#setLocation(double, double)
  	 */
  	public void setLocation(int x, int y) {
  		this.x = x;
  		this.y = y;
  	}
  	
  	/**
  	 * Convert point to string format.
  	 */
  	public String toString() {
  		return "ImagePoint["+this.x+","+this.y+"]";
  	}
  	
  	/**
  	 * Addition of two points (as in vector space).
  	 * @param p Point to add to current point.
  	 */
  	public ImagePoint add(ImagePoint p) {
  		this.x += p.x;
  		this.y += p.y;
  		return this;
  	}
  	
  	/** Addition of the current point to the specified list of points.
  	 * The spirit is opposed as the add to point method: here the coordinates
  	 * of the object point is added to the coordinates of the points in the list.
  	 * @param listOfPoints List of points to translate.
  	 * @return The translated list of points.
  	 */
  	public List<ImagePoint> addTo(List<ImagePoint> listOfPoints) {
  		List<ImagePoint> modifiedList = new Vector<>();
  		
  		for (ImagePoint p : listOfPoints) {
  			modifiedList.add(p.add(this));
  		}
  		
  		return modifiedList;
  	}
  	
  	/**
  	 * Subtraction of two points (as in vector space).
  	 * @param p Point to subtract to current point.
  	 */
  	public ImagePoint subtract(ImagePoint p) {
  		this.x -= p.x;
  		this.y -= p.y;
  		return this;
  	}
  	
  	/**
  	 * Subtraction of the current point to the specified list of points.
  	 * The spirit is opposed as the subtract to point method: here the coordinates
  	 * of the object point is subtracted to the coordinates of the points in the list.
  	 * @param listOfPoints List of points to translate.
  	 * @return The translated list of points.
  	 */
  	public List<ImagePoint> subtractTo(List<ImagePoint> listOfPoints) {
  		List<ImagePoint> modifiedList = new Vector<>();
  		
  		for (ImagePoint p : listOfPoints) {
  			modifiedList.add(p.add(this));
  		}
  		
  		return modifiedList;
  	}
  	
  	/**
  	 * Compute euclidian distance between two points. 
  	 * @param p1 First input point.
  	 * @param p2 Second input point.
  	 * @return Euclidian distance between input points.
  	 */
  	public static double distanceBetweenPoints(ImagePoint p1, ImagePoint p2) {
  		return Math.sqrt(ImagePoint.squaredDistanceBetweenPoints(p1, p2));
  	}
  	
  	/**
  	 * Compute euclidian squared distance between two points. 
  	 * @param p1 First input point.
  	 * @param p2 Second input point.
  	 * @return Euclidian squared distance between input points.
  	 */
  	public static double squaredDistanceBetweenPoints(ImagePoint p1, ImagePoint p2) {
  		double diffX = p1.x - p2.x;
  		double diffY = p1.y - p2.y;
  		
  		return diffX*diffX + diffY*diffY;
  	}
  	
  	/**
  	 * Compute euclidian distance of this point to the input.
  	 * @param p Input point.
  	 * @return Euclidian distance between this point and the input point.
  	 */
  	public double squaredDistanceToPoint(ImagePoint p) {
  		return ImagePoint.squaredDistanceBetweenPoints(this, p);
  	}
  	
  	/**
  	 * Compute euclidian distance of this point to the input.
  	 * @param p Input point.
  	 * @return Euclidian distance between this point and the input point.
  	 */
  	public double distanceToPoint(ImagePoint p) {
  		return ImagePoint.distanceBetweenPoints(this, p);
  	}
  	
  	/**
  	 * Estimate a straight line in Hesse normal form with a list of points.
  	 * The line is estimated using regression. Instead of least squares, the
  	 * Theil-Sen estimator is applied (robust estimator using the median).
  	 * Note that p0 is not supposed to be in the list of points (no checking
  	 * will be done for that).
  	 * @param p0 A point that is known to be on the line to estimate.
  	 * @param points A list of points used to estimate the line.
  	 * @return The estimated Hough point (straight line in Hesse normal form).
  	 */
  	public static HoughPoint estimateHoughPoint(ImagePoint p0, List<ImagePoint> points) {
  		// Since angles are circular quantities, it does not have
  		// a proper ordering relationship and we need to center the
  		// angles first to their center of mass.
  		
  		// Initialize
  