optics
Class Grid

java.lang.Object
  extended by optics.Optics
      extended by optics.Grid

public class Grid
extends Optics

Class to define the sampling grid for a optical image and allow access using continuous variables.


Field Summary
protected  javax.vecmath.Point2d centre
          Reference point for the Grid, wrt to the centre.
protected  double dx
          Sample interval in x direction
protected  double dy
          Sample interval in y direction
protected  int height
          Height of the grid in pixels
protected  int width
          Width of the grid in pixels
 
Fields inherited from class optics.Optics
DEFAULT_WAVELENGTH, errorStream, fmt, MICRONS
 
Constructor Summary
Grid()
          Default constructor to for a grid of size 0
Grid(Grid g)
          Constructor with all parameters set by specified Grid
Grid(int w, int h)
          Constuctor with centre defaulted to 0,0 and sample interval to 1.0,1.0,1.0
Grid(int w, int h, double dx, double dy)
          Constructor with centre defaulted to 0,0
Grid(int w, int h, double dx, double dy, double xc, double yc)
          General constructor setting all parameters
 
Method Summary
 Grid clone()
          Return a clone of the current Grid.
 javax.vecmath.Point2d getCentre()
          Method to get the centre
 double getDeltaX()
          Method to get the x-sample
 double getDeltaY()
          Method to get the y-sample
 int getHeight()
          Method to get the height
 double getMaxRadius()
          Method to get the maximum radius of the Grid.
 javax.vecmath.Point2d getPoint(int i, int j)
          Method to get the Point2d of a specified pixel taking into account centre and sample intervals.
 javax.vecmath.Point2d getPoint(javax.vecmath.Point2i p)
          Method to get the Point2d of a specified pixel taking into account centre and sample intervals.
 javax.vecmath.Point2i getSample(javax.vecmath.Point2d p)
          Method to get the sample (pixel) closest to the specified point taking into account centre and scaling.
 javax.vecmath.Point2d getSamplePoint(javax.vecmath.Point2d p)
          Method to get the scaled sample location being the location of eth given point on the pixel grid.
 int getWidth()
          Method to get the width
 void setCentre(double x, double y)
          Method to set the centre
 void setCentre(javax.vecmath.Point2d pt)
          Method to set the centre
 void setSampleGrid(double dx, double dy)
          Method to set the sampling grid
 java.lang.String toString()
          Method to return information String
 
Methods inherited from class optics.Optics
getDefaultWaveLength, getErrorStream, getFormatString, getName, getStaticName, getVersion, printError, setDefaultWaveLength, setErrorStream, setFormatString, setMicrons
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

width

protected int width
Width of the grid in pixels


height

protected int height
Height of the grid in pixels


centre

protected javax.vecmath.Point2d centre
Reference point for the Grid, wrt to the centre.


dx

protected double dx
Sample interval in x direction


dy

protected double dy
Sample interval in y direction

Constructor Detail

Grid

public Grid(int w,
            int h,
            double dx,
            double dy,
            double xc,
            double yc)
General constructor setting all parameters

Parameters:
w - the width
h - the height
dx - x sample interval
dy - y sample interval
xc - x centre
yc - y centre

Grid

public Grid(int w,
            int h,
            double dx,
            double dy)
Constructor with centre defaulted to 0,0

Parameters:
w - the width
h - the height
dx - x sample interval
dy - y sample interval

Grid

public Grid(int w,
            int h)
Constuctor with centre defaulted to 0,0 and sample interval to 1.0,1.0,1.0

Parameters:
w - the width
h - the height

Grid

public Grid()
Default constructor to for a grid of size 0


Grid

public Grid(Grid g)
Constructor with all parameters set by specified Grid

Parameters:
g - the specifying Grid
Method Detail

clone

public Grid clone()
Return a clone of the current Grid.

Overrides:
clone in class java.lang.Object
Returns:
Grid clone of current Grid

setSampleGrid

public void setSampleGrid(double dx,
                          double dy)
Method to set the sampling grid

Parameters:
dx - the x sample interval
dy - the y sample interval

setCentre

public void setCentre(double x,
                      double y)
Method to set the centre

Parameters:
x - the x location
y - the y location

setCentre

public void setCentre(javax.vecmath.Point2d pt)
Method to set the centre

Parameters:
pt - the centre

getWidth

public int getWidth()
Method to get the width

Returns:
int the width

getHeight

public int getHeight()
Method to get the height

Returns:
int the height

getMaxRadius

public double getMaxRadius()
Method to get the maximum radius of the Grid.

Returns:
double the maximum radius

getCentre

public javax.vecmath.Point2d getCentre()
Method to get the centre

Returns:
Point2d the centre.

getDeltaX

public double getDeltaX()
Method to get the x-sample

Returns:
double the x-sample internal

getDeltaY

public double getDeltaY()
Method to get the y-sample

Returns:
double the y-sample internal

toString

public java.lang.String toString()
Method to return information String

Overrides:
toString in class java.lang.Object

getPoint

public javax.vecmath.Point2d getPoint(int i,
                                      int j)
Method to get the Point2d of a specified pixel taking into account centre and sample intervals.

Parameters:
i - the x pixel location
j - the y pixel location
Returns:
Point2d the location

getPoint

public javax.vecmath.Point2d getPoint(javax.vecmath.Point2i p)
Method to get the Point2d of a specified pixel taking into account centre and sample intervals.

Parameters:
p - the pixel Point
Returns:
Point2D.Float the location

getSamplePoint

public javax.vecmath.Point2d getSamplePoint(javax.vecmath.Point2d p)
Method to get the scaled sample location being the location of eth given point on the pixel grid. There is no check that the calculated point is within the grid.

This method is the inverse of getPoint(int, int)

Parameters:
p - the specifed point.
Returns:
Point2d the location on pixel grid

getSample

public javax.vecmath.Point2i getSample(javax.vecmath.Point2d p)
Method to get the sample (pixel) closest to the specified point taking into account centre and scaling.

If outside the grid, both components will be set to -1.

Parameters:
p - the specified point.
Returns:
Point2i closest pixel location.