hhreco.toolbox
Class Util

java.lang.Object
  extended byhhreco.toolbox.Util

public class Util
extends java.lang.Object

General utilities.


Constructor Summary
Util()
           
 
Method Summary
static double distance(double x1, double y1, double x2, double y2)
          Return the Euclidean distance between two points, (x1, y1) and (x2, y2).
static java.awt.geom.Rectangle2D getBounds(TimedStroke[] s)
          Return the bounding box enclosing the set of strokes.
static java.awt.geom.AffineTransform normScaling(TimedStroke[] strokes, double height, double width)
          Scale the set of strokes uniformly (maintaining the aspect ratio).
static double pathLength(double[] xvals, double[] yvals, int num)
          Return the total pathlength by summing over the distance of consecutive points in the array.
static double pathLength(double[] xvals, double[] yvals, int startIndex, int endIndex)
          calculate the path length starting from the startIndex to the endIndex (inclusive) of the points in the array.
static double pathLength(TimedStroke s)
          Return the path length of a stroke by enumerating over the points in the stroke and summing up the distances between every two consecutive points.
static void strokesToArrays(TimedStroke[] strokes, double[][] xvals, double[][] yvals, int[] npoints)
          Store the stroke points in array forms.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

strokesToArrays

public static void strokesToArrays(TimedStroke[] strokes,
                                   double[][] xvals,
                                   double[][] yvals,
                                   int[] npoints)
Store the stroke points in array forms. This will become unnecessary once I do some rewriting of TimedStroke class. xvals, yvals and npoints are pre-allocated arrays and will be filled in by this method. xvals[strokeIndex][pointIndex]


getBounds

public static java.awt.geom.Rectangle2D getBounds(TimedStroke[] s)
Return the bounding box enclosing the set of strokes.


normScaling

public static java.awt.geom.AffineTransform normScaling(TimedStroke[] strokes,
                                                        double height,
                                                        double width)
Scale the set of strokes uniformly (maintaining the aspect ratio). The scaling factor is dependent on the longer side of the bounding box that encloses the strokes. If the height of the bounding box is bigger than the width, the scale factor would be height/box.height. Otherwise, it is width/box.width. The strokes are also translated such that the upper left point of the bounding box is at the origin. Return the transform performed on the set of input strokes.


distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2)
Return the Euclidean distance between two points, (x1, y1) and (x2, y2).


pathLength

public static double pathLength(double[] xvals,
                                double[] yvals,
                                int num)
Return the total pathlength by summing over the distance of consecutive points in the array.


pathLength

public static double pathLength(double[] xvals,
                                double[] yvals,
                                int startIndex,
                                int endIndex)
calculate the path length starting from the startIndex to the endIndex (inclusive) of the points in the array.


pathLength

public static double pathLength(TimedStroke s)
Return the path length of a stroke by enumerating over the points in the stroke and summing up the distances between every two consecutive points.