Class ncsa.horizon.coordinates.transforms.AbsToRelCoordTransform
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ncsa.horizon.coordinates.transforms.AbsToRelCoordTransform

java.lang.Object
   |
   +----java.util.Observable
           |
           +----ncsa.horizon.coordinates.CoordTransform
                   |
                   +----ncsa.horizon.coordinates.transforms.AbsToRelCoordTransform

public class AbsToRelCoordTransform
extends CoordTransform
an object for transforming positions from absolute positions to positions relative to a reference position.

See the documentation for the super class, CoordTransform, for a general description of how a transform is used.

The transform applied by this class is governed by two basic pieces of data: a reference position and a stepsize. The stepsize, a scale factor to be applied to width of a voxel, is usually left to its default value of 1.0. The reference position is the absolute position that the relative positions are referred to; that is, the reference position in the old system will be shifted to 0.0 in the new, transformed system.

When one instantiates this class, one usually indicates whether the transform can adapt its reference position and stepsize according to the CoordinateSystem it gets attached to. If this transform is adaptable (e.g. willAdapt() returns true), then when the transform is attached to a CoordinateSystem, it will change its reference position to that found in the system's metadata, and the stepsize will be set to 1.0. If it is not adaptable, it will use the reference position and stepsize set at construction.

For example, if one wants to make a CoordinateSystem give positions in relative coordinates, one can:

    CoordinateSystem csys;
    int numaxes;
    ...             // csys and numaxes are set
    CoordTransform t = new AbsToRelCoordTransform(numaxes);
    csys.attachTransform(t);
The csys system will now print out its coordinate positions relative to its native reference position. However, if we want positions be be relative to some other reference, we can instead:
    double[] ref = { 20.0, 31.53, -15.8 };
    CoordTransform t = new AbsToRelCoordTransform(ref.length, ref, false);
    csys.attachTransform(t); 
Now suppose the system already prints out relative coordinate positions; We can change the positions to absolute ones by attaching this transform in reverse:
    double[] ref = { 20.0, 31.53, -15.8 };
    CoordTransform t = new AbsToRelCoordTransform(ref.length, ref, false);
    csys.attachTransform(t, false); 
In this case, we needed to provide the reference position, since the native reference (if the positions really are relative coordinates) is likely to be zero. However, it may not be, and you can allow the transform use that reference when attached in reverse:
    CoordTransform t = new AbsToRelCoordTransform(numaxes, null, true);
    csys.attachTransform(t, false); 
This will cause the zero position in the native system to be shifted to the native reference position; in addition, -1.0 will be used as the stepsize. This turns about to be exactly equivalent to our first example.


Variable Index

 o adapt
if true, this transform--when attached to a CoordinateSystem--will replace its reference position data with that of the CoordinateSystem being attached to.
 o delegate

Constructor Index

 o AbsToRelCoordTransform()
create a AbsToRelCoordTransform object with default values, assuming it will operate on up to 2 axes.
 o AbsToRelCoordTransform(int)
create a AbsToRelCoordTransform object with default values.
 o AbsToRelCoordTransform(int, double[], boolean)
create a AbsToRelCoordTransform object specifying all internal data.
 o AbsToRelCoordTransform(int, double[], double[], boolean)
create a AbsToRelCoordTransform object specifying all internal data.
 o AbsToRelCoordTransform(Metadata)
create a linear transform based on the specified metadata using the horizon schema.

Method Index

 o clone()
create a copy of this Transform
 o forward(double[])
apply a forward tranform on an input position.
 o forward(double[], int[])
apply a forward tranform on an input position.
 o getInNaxes()
return the minimum number of axes that the forward transform operates on.
 o getMaxNaxes()
return the maximum number of axes this transform operates on
 o getMetadata(Metadata, boolean, int[])
update the input Metadata object to reflect the changes that this tranform makes to a coordinate position.
 o getOutNaxes()
return the minimum number of axes that results from the forward transform.
 o getRefvalue()
return a copy of the axis reference values for all axes.
 o getRefvalue(int)
return the axis reference value for the specified axis.
 o getStepsize()
return the axis step size for each axis.
 o getStepsize(int)
return the axis step size for the specified axis.
 o init(CoordinateSystem, boolean, int[])
initialize this transform according to the system it is to be applied to.
 o reverse(double[])
apply a reverse tranform on an input position.
 o reverse(double[], int[])
apply a reverse tranform on an input position
 o setMaxNaxes(int)
set the maximum number of axes this transform operates on
 o setRefvalue(double[])
set the axis reference value for each axis.
 o setRefvalue(int, double)
set the axis reference value for the specified axis.
 o setStepsize(double[])
set the axis step size for each axis.
 o setStepsize(int, double)
set the axis step size for the specified axis.
 o setToAdapt(boolean)
set whether this transform should adapt its internal data according to the reference position data of the CoordinateSystem it gets attached to.
 o willAdapt()
return whether the data internal to this object will get update upon attachment to a CoordinateSystem.

Variables

 o adapt
  protected boolean adapt
if true, this transform--when attached to a CoordinateSystem--will replace its reference position data with that of the CoordinateSystem being attached to.
 o delegate
  protected LinearCoordTransform delegate

Constructors

 o AbsToRelCoordTransform
  public AbsToRelCoordTransform()
create a AbsToRelCoordTransform object with default values, assuming it will operate on up to 2 axes. By default, willAdapt() will return true.
 o AbsToRelCoordTransform
  public AbsToRelCoordTransform(int naxes)
create a AbsToRelCoordTransform object with default values. By default, willAdapt() will return true.
Parameters:
naxes - the maximum number of axes this transform can operate on
 o AbsToRelCoordTransform
  public AbsToRelCoordTransform(int naxes,
                                double refval[],
                                boolean adapt)
create a AbsToRelCoordTransform object specifying all internal data. Missing values in the input array are set to zero
Parameters:
naxes - the maximum number of axes this transform can operate on
refval - the position in the "output" system (the system forward() transforms to) that is equal to the the refpos position. Default equals 0.
adapt - if false, these values should not be updated when attached to a CoordinateSystem. (If one intends intend to attach this AbsToRelCoordTransform to a CoordinateSystem, this value will not be used.)
 o AbsToRelCoordTransform
  public AbsToRelCoordTransform(int naxes,
                                double refval[],
                                double stepsize[],
                                boolean adapt)
create a AbsToRelCoordTransform object specifying all internal data. Missing values in the input arrays are set to default values: 0.0 for refval and 1.0 for stepsize.
Parameters:
naxes - the maximum number of axes this transform can operate on
refval - the position in the "output" system (the system forward() transforms to) that is equal to the the refpos position. Default equals 0.
stepsize - the size of a voxel of the "output" system (the system that forward() transforms to) in units of the "input" system
adapt - if false, these values should not be updated when attached to a CoordinateSystem. (If one intends intend to attach this AbsToRelCoordTransform to a CoordinateSystem, this value will not be used.)
 o AbsToRelCoordTransform
  public AbsToRelCoordTransform(Metadata md) throws IllegalTransformException
create a linear transform based on the specified metadata using the horizon schema.

Methods

 o forward
  public synchronized double[] forward(double position[],
                                       int axisIndices[])
apply a forward tranform on an input position.
Parameters:
position - an array giving the input position to transform
axisIndices - an array containing the indices of the position array that should be used in the tranformation. The order of the indices indicate how the position should be interpreted by the transform.
Overrides:
forward in class CoordTransform
 o forward
  public synchronized double[] forward(double position[])
apply a forward tranform on an input position.
Parameters:
position - an array giving the input position to transform
Overrides:
forward in class CoordTransform
 o reverse
  public synchronized double[] reverse(double position[],
                                       int axisIndices[])
apply a reverse tranform on an input position
Parameters:
position - an array giving the input position to transform
axisIndices - an array containing the indices of the position array that should be used in the tranformation. The order of the indices indicate how the position should be interpreted by the transform.
Overrides:
reverse in class CoordTransform
 o reverse
  public synchronized double[] reverse(double position[])
apply a reverse tranform on an input position. A list of axis indices is assumed (usually { 0, ... getOutNAxes()-1 }).
Parameters:
position - an array giving the input position to transform
Overrides:
reverse in class CoordTransform
 o getInNaxes
  public int getInNaxes()
return the minimum number of axes that the forward transform operates on. This value is equal to the minimum number of axes that results from the reverse transform. This value is often equal to the that returned by getOutNaxes(), but is not required to.
Overrides:
getInNaxes in class CoordTransform
 o getOutNaxes
  public int getOutNaxes()
return the minimum number of axes that results from the forward transform. This value is equal to the minimum number of axes that the reverse transform operates on. This value is often equal to the that returned by getInNaxes(), but is not required to.
Overrides:
getOutNaxes in class CoordTransform
 o getMaxNaxes
  public int getMaxNaxes()
return the maximum number of axes this transform operates on
 o setMaxNaxes
  public synchronized void setMaxNaxes(int naxes) throws ArrayIndexOutOfBoundsException
set the maximum number of axes this transform operates on
 o setRefvalue
  public synchronized void setRefvalue(int axis,
                                       double in) throws ArrayIndexOutOfBoundsException
set the axis reference value for the specified axis. The reference value is position along a world coordinate axis that corresponds to the data location given by the "refposition" metadatum.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
in - value to be set
 o getRefvalue
  public synchronized double getRefvalue(int axis) throws ArrayIndexOutOfBoundsException
return the axis reference value for the specified axis. The reference value is position along a world coordinate axis that corresponds to the data location given by the "refposition" metadatum.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
 o setRefvalue
  public synchronized void setRefvalue(double in[])
set the axis reference value for each axis. The reference value is position along a world coordinate axis that corresponds to the data location given by the "refposition" metadatum.
Parameters:
in - values to be set; missing or extra values are ignored
 o getRefvalue
  public synchronized double[] getRefvalue()
return a copy of the axis reference values for all axes. The reference value is position along a world coordinate axis that corresponds to the data location given by the "refposition" metadatum.
 o setStepsize
  public synchronized void setStepsize(int axis,
                                       double in) throws ArrayIndexOutOfBoundsException
set the axis step size for the specified axis. The step size is length of a voxel along an axis in world coordinate units.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
in - value to be set
 o getStepsize
  public synchronized double getStepsize(int axis) throws ArrayIndexOutOfBoundsException
return the axis step size for the specified axis. The step size is length of a voxel along an axis in world coordinate units.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
 o setStepsize
  public synchronized void setStepsize(double in[])
set the axis step size for each axis. The step size is length of a voxel along an axis in world coordinate units.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
in - value to be set
 o getStepsize
  public synchronized double[] getStepsize()
return the axis step size for each axis. The step size is length of a voxel along an axis in world coordinate units.
Parameters:
axis - the index of the axis to be set (first axis has index 0)
in - value to be set
 o clone
  public synchronized Object clone()
create a copy of this Transform
Overrides:
clone in class CoordTransform
 o getMetadata
  public synchronized Metadata getMetadata(Metadata in,
                                           boolean forward,
                                           int axisIndices[])
update the input Metadata object to reflect the changes that this tranform makes to a coordinate position. In general, this method will actually edit the contents of the input Metadata when changes are necessary.
Overrides:
getMetadata in class CoordTransform
 o setToAdapt
  public void setToAdapt(boolean doadapt)
set whether this transform should adapt its internal data according to the reference position data of the CoordinateSystem it gets attached to. If the input is true, then when this transform is attached to a CoordinateSystem object, it will ignore its own reference position information; instead, it will look up the current reference position of the system and then reset its internal parameters to convert positions in that system to positions relative to that reference position.
 o willAdapt
  public boolean willAdapt()
return whether the data internal to this object will get update upon attachment to a CoordinateSystem.
 o init
  public void init(CoordinateSystem csys,
                   boolean forward,
                   int axisIndices[]) throws IllegalTransformException
initialize this transform according to the system it is to be applied to. This method is usually called by a CoordinateSystem object when the transform is attached to it.
Throws: IllegalTransformException
if the csys has a non-positive number of axes
Overrides:
init in class CoordTransform

All Packages  Class Hierarchy  This Package  Previous  Next  Index