PathPlan
Class Discretizer

java.lang.Object
  extended by PathPlan.Discretizer

public class Discretizer
extends java.lang.Object

Handles 2D coordinate transforms and discretization.


Nested Class Summary
 class Discretizer.Point
          A point which has corresponding coordinates in the discrete and continuous worlds.
 class Discretizer.Rectangle
          A rectangle which has corresponding coordinates in the discrete and continuous worlds.
 
Constructor Summary
Discretizer()
           
 
Method Summary
 int discretizeOval(Discretizer.Rectangle rect, int[][] result)
          Find all of the discrete coordinates within an axis-oriented elliptical region.
 double getContX(int x)
          Translate discrete to continuous X.
 double getContY(int y)
          Translate discrete to continuous Y.
 int getDiscX(double x)
          Translate continuous to discrete X.
 double getDiscXFraction(double x)
          Translate continuous to discrete X without rounding (useful only as an intermediate result).
 int getDiscY(double y)
          Translate continuous to discrete Y.
 double getDiscYFraction(double y)
          Translate continuous to discrete Y without rounding (useful only as an intermediate result).
 int getHeight()
          Get discrete y range.
 int getWidth()
          Get discrete x range.
 double getXmax()
          Get continuous largest x.
 double getXmin()
          Get continuous lowest x.
 double getYmax()
          Get continuous largest y.
 double getYmin()
          Get continuous smallest y.
 Discretizer.Point Point(double x, double y)
          Make a point from its continuous coordinates.
 Discretizer.Point Point(int x, int y)
          Make a point from its discrete coordinates.
 Discretizer.Rectangle Rectangle(double xmin, double ymin, double xmax, double ymax)
          Make a Rectangle from its continuous coordinates.
 Discretizer.Rectangle Rectangle(int xmin, int ymin, int xmax, int ymax)
          Make a Rectangle from its discrete coordinates.
 void setContinuousRange(double xmin, double ymin, double xmax, double ymax)
          Set the range of the continuous coordinates
 void setDiscreteRange(int w, int h)
          Set the range of the discrete coordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Discretizer

public Discretizer()
Method Detail

Point

public Discretizer.Point Point(int x,
                               int y)
Make a point from its discrete coordinates.


Point

public Discretizer.Point Point(double x,
                               double y)
Make a point from its continuous coordinates.


Rectangle

public Discretizer.Rectangle Rectangle(int xmin,
                                       int ymin,
                                       int xmax,
                                       int ymax)
Make a Rectangle from its discrete coordinates.


Rectangle

public Discretizer.Rectangle Rectangle(double xmin,
                                       double ymin,
                                       double xmax,
                                       double ymax)
Make a Rectangle from its continuous coordinates.


discretizeOval

public int discretizeOval(Discretizer.Rectangle rect,
                          int[][] result)
Find all of the discrete coordinates within an axis-oriented elliptical region.

Parameters:
rect - The bounding rectangle of the ellipse.
result - An int[2][]. The x coordinates will be returned in result[0] while the y coordinates will be returned in result[1]. If result[0] and result[1] are not big enough to hold all of the coordinates, they will be reallocated.
Returns:
The number of points computed. Elements of result[][] past this number of entries are invalid.

setDiscreteRange

public void setDiscreteRange(int w,
                             int h)
Set the range of the discrete coordinates


setContinuousRange

public void setContinuousRange(double xmin,
                               double ymin,
                               double xmax,
                               double ymax)
Set the range of the continuous coordinates


getContX

public final double getContX(int x)
Translate discrete to continuous X.


getContY

public final double getContY(int y)
Translate discrete to continuous Y.


getDiscX

public final int getDiscX(double x)
Translate continuous to discrete X.


getDiscXFraction

public final double getDiscXFraction(double x)
Translate continuous to discrete X without rounding (useful only as an intermediate result).


getDiscY

public final int getDiscY(double y)
Translate continuous to discrete Y.


getDiscYFraction

public final double getDiscYFraction(double y)
Translate continuous to discrete Y without rounding (useful only as an intermediate result).


getWidth

public final int getWidth()
Get discrete x range.


getHeight

public final int getHeight()
Get discrete y range.


getXmin

public final double getXmin()
Get continuous lowest x.


getXmax

public final double getXmax()
Get continuous largest x.


getYmin

public final double getYmin()
Get continuous smallest y.


getYmax

public final double getYmax()
Get continuous largest y.