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 Summary
ConstructorsConstructorDescriptionGridCoordinate
(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 Summary
Modifier and TypeMethodDescriptionclone()
Make a clone of this grid coordinatedouble
getDelta()
Get the computed coordinate spacing.double
getFraction
(double val) Get the fractional part for use in interpolation.int
getIndex
(double val) Returns an index [0..numPoints-2] such that the grid values index and index+1 enclose the value.double
getMax()
Get the maximum value of the grid coordinate.double
getMax
(int index) Get the maximum for a given indexdouble
getMin()
Get the minimum value of the grid coordinate.double
getMin
(int index) Get the minimum for a given indexgetName()
Get the name of the coordinateint
Get the number of points on the grid (including endpoints).int
getRoundedIndex
(double val) Gets the nearest index [0..numPoints-1] for nearest neighbordouble
getValue
(int index) Get the value at a given index.double[]
Get the values of the grid pointsboolean
inRange
(double q) Check whether a value is in rangevoid
Set the name of the grid coordinate.toString()
Create a string representation.
-
Constructor Details
-
GridCoordinate
Construct a grid coordinate.- Parameters:
name
- the name of the coordinatemin
- the minimum valuemax
- the maximum valuenumPoints
- the number of points (including ends)
-
GridCoordinate
Construct a grid coordinate.- Parameters:
name
- the name of the coordinatemin
- the minimum valuemax
- the maximum valuenumPoints
- the number of points (including ends)
-
-
Method Details
-
getValues
public double[] getValues()Get the values of the grid points- Returns:
- the values of the grid points
-
getRoundedIndex
public 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
-
getIndex
public 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.
-
getValue
public double getValue(int index) Get the value at a given index.- Parameters:
index
- the index- Returns:
- the value at that index.
-
toString
Create a string representation. -
getNumPoints
public int getNumPoints()Get the number of points on the grid (including endpoints).- Returns:
- the number of points on the grid (including endpoints).
-
getDelta
public double getDelta()Get the computed coordinate spacing.- Returns:
- the coordinate spacing.
-
getFraction
public double getFraction(double val) Get the fractional part for use in interpolation.- Parameters:
val
- the value- Returns:
- the fraction of spacing.
-
getMin
public double getMin()Get the minimum value of the grid coordinate.- Returns:
- the minimum value of the grid coordinate.
-
getMax
public double getMax()Get the maximum value of the grid coordinate.- Returns:
- the maximum value of the grid coordinate.
-
getName
Get the name of the coordinate- Returns:
- the name of the coordinate
-
setName
Set the name of the grid coordinate.- Parameters:
name
- the name of the grid coordinate
-
getMin
public double getMin(int index) Get the minimum for a given index- Parameters:
index
- the index- Returns:
- the min for the given index
-
getMax
public double getMax(int index) Get the maximum for a given index- Parameters:
index
- the index- Returns:
- the max for the given index
-
inRange
public boolean inRange(double q) Check whether a value is in range- Parameters:
q
- the value- Returns:
true
if the value is between min and max
-
clone
Make a clone of this grid coordinate
-