Package cnuphys.magfield
Class GridCoordinate
java.lang.Object
cnuphys.magfield.GridCoordinate
This class holds the grid parameters for one direction. The constructor is
 provided the min, max and number of points (inclusive, i.e., including the
 end points) and the step is computed.
- Version:
- 1.0
- Author:
- David Heddle, Nicole Schumacher
- 
Constructor SummaryConstructorsConstructorDescriptionGridCoordinate(String name, double min, double max, int numPoints) Construct a grid coordinate.GridCoordinate(String name, float min, float max, int numPoints) Construct a grid coordinate.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Make a clone of this grid coordinatedoublegetDelta()Get the computed coordinate spacing.doublegetFraction(double val) Get the fractional part for use in interpolation.intgetIndex(double val) Returns an index [0..numPoints-2] such that the grid values index and index+1 enclose the value.doublegetMax()Get the maximum value of the grid coordinate.doublegetMax(int index) Get the maximum for a given indexdoublegetMin()Get the minimum value of the grid coordinate.doublegetMin(int index) Get the minimum for a given indexgetName()Get the name of the coordinateintGet the number of points on the grid (including endpoints).intgetRoundedIndex(double val) Gets the nearest index [0..numPoints-1] for nearest neighbordoublegetValue(int index) Get the value at a given index.double[]Get the values of the grid pointsbooleaninRange(double q) Check whether a value is in rangevoidSet the name of the grid coordinate.toString()Create a string representation.
- 
Constructor Details- 
GridCoordinateConstruct a grid coordinate.- Parameters:
- name- the name of the coordinate
- min- the minimum value
- max- the maximum value
- numPoints- the number of points (including ends)
 
- 
GridCoordinateConstruct a grid coordinate.- Parameters:
- name- the name of the coordinate
- min- the minimum value
- max- the maximum value
- numPoints- the number of points (including ends)
 
 
- 
- 
Method Details- 
getValuespublic double[] getValues()Get the values of the grid points- Returns:
- the values of the grid points
 
- 
getRoundedIndexpublic int getRoundedIndex(double val) Gets the nearest index [0..numPoints-1] for nearest neighbor- Parameters:
- val- the value
- Returns:
- the nearest index for nearest neighbor
 
- 
getIndexpublic int getIndex(double val) Returns an index [0..numPoints-2] such that the grid values index and index+1 enclose the value. A return of 0 means the value is between min and min + delta; A return of numPoints-2 means the value is between max - delta and max. A return value of -1 indicates out of range.- Parameters:
- val- the value to test
- Returns:
- an index [0..numPoints-2] such that the grid values index and index+1 enclose the value.
 
- 
getValuepublic double getValue(int index) Get the value at a given index.- Parameters:
- index- the index
- Returns:
- the value at that index.
 
- 
toStringCreate a string representation.
- 
getNumPointspublic int getNumPoints()Get the number of points on the grid (including endpoints).- Returns:
- the number of points on the grid (including endpoints).
 
- 
getDeltapublic double getDelta()Get the computed coordinate spacing.- Returns:
- the coordinate spacing.
 
- 
getFractionpublic double getFraction(double val) Get the fractional part for use in interpolation.- Parameters:
- val- the value
- Returns:
- the fraction of spacing.
 
- 
getMinpublic double getMin()Get the minimum value of the grid coordinate.- Returns:
- the minimum value of the grid coordinate.
 
- 
getMaxpublic double getMax()Get the maximum value of the grid coordinate.- Returns:
- the maximum value of the grid coordinate.
 
- 
getNameGet the name of the coordinate- Returns:
- the name of the coordinate
 
- 
setNameSet the name of the grid coordinate.- Parameters:
- name- the name of the grid coordinate
 
- 
getMinpublic double getMin(int index) Get the minimum for a given index- Parameters:
- index- the index
- Returns:
- the min for the given index
 
- 
getMaxpublic double getMax(int index) Get the maximum for a given index- Parameters:
- index- the index
- Returns:
- the max for the given index
 
- 
inRangepublic boolean inRange(double q) Check whether a value is in range- Parameters:
- q- the value
- Returns:
- trueif the value is between min and max
 
- 
cloneMake a clone of this grid coordinate
 
-