edu.mit.sketch.util
Class LinearFit

java.lang.Object
  |
  +--edu.mit.sketch.util.LinearFit

public class LinearFit
extends Object

This class has useful functions for linear line matching. Some adapted from numerical recipes book.


Field Summary
static int ROTATION_METHOD
          Constant corresponding to deriving direction using sliding window and rotation mehod.
static int SIMPLE_TANGENTS_METHOD
          Constant corresponding to deriving direction using simple tangents.
static int SWODR_METHOD
          Constant corresponding to deriving direction using sliding window and the ODR package.
 
Constructor Summary
LinearFit()
           
 
Method Summary
static double findAngle(double[] x, double[] y)
          Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points.
static double findAngle(double[] x, double[] y, int start_index, int end_index)
          Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points.
static double findAngle(double[] x, double[] y, int start_index, int end_index, int partitions)
          Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points.
static double findAngle(Point[] points)
          Return the angle -- in radians -- that best approximates the slope of the line that best fits the data points.
static double findAngle2(double[] x, double[] y, int start_index, int end_index, int depth)
          Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points.
static double findAngleViaODR(double[] x, double[] y)
          Do a linear fit.
static double[] fit(double[] x, double[] y)
          Do a linear fit.
static double[] fit2(double[] x, double[] y)
          Do a linear fit.
static String fitMethodToString(int fit_method)
          Return a String giving info about the fit method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIMPLE_TANGENTS_METHOD

public static final int SIMPLE_TANGENTS_METHOD
Constant corresponding to deriving direction using simple tangents.

SWODR_METHOD

public static final int SWODR_METHOD
Constant corresponding to deriving direction using sliding window and the ODR package.

ROTATION_METHOD

public static final int ROTATION_METHOD
Constant corresponding to deriving direction using sliding window and rotation mehod.
Constructor Detail

LinearFit

public LinearFit()
Method Detail

fit

public static double[] fit(double[] x,
                           double[] y)
Do a linear fit. Return a and b in an array. (y = ax+b)

findAngle

public static double findAngle(double[] x,
                               double[] y,
                               int start_index,
                               int end_index,
                               int partitions)
Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points. Do this for points [start_index, end_index] (including start and end points.

findAngle2

public static double findAngle2(double[] x,
                                double[] y,
                                int start_index,
                                int end_index,
                                int depth)
Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points. Do this for points [start_index, end_index] (including start and end points.

findAngle

public static double findAngle(double[] x,
                               double[] y,
                               int start_index,
                               int end_index)
Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points. Do this for points [start_index, end_index] (including start and end points.

findAngle

public static double findAngle(Point[] points)
Return the angle -- in radians -- that best approximates the slope of the line that best fits the data points.

findAngle

public static double findAngle(double[] x,
                               double[] y)
Return the angle -- in radians -- that best approximates the slope of the line that best fits x, y data points.

fit2

public static double[] fit2(double[] x,
                            double[] y)
Do a linear fit. Return a and b in an array. (y = ax+b)

findAngleViaODR

public static double findAngleViaODR(double[] x,
                                     double[] y)
Do a linear fit. Return then angle that the fitted line makes with the x axis.

fitMethodToString

public static String fitMethodToString(int fit_method)
Return a String giving info about the fit method.