uk.ac.starlink.ast
Class Transformer2

java.lang.Object
  extended by uk.ac.starlink.ast.Transformer
      extended by uk.ac.starlink.ast.Transformer2

public abstract class Transformer2
extends Transformer

Defines a custom two-dimensional coordinate transformation function. This abstract subclass of Transformer is provided for convenience when only a 2-d transformation is required. Subclasses need to implement the tran2 method, which is somewhat more convenient than Transformer's tranP method.

Version:
$Id$
Author:
Mark Taylor (Starlink)

Constructor Summary
Transformer2()
           
 
Method Summary
 boolean canTransformCoords(int nin, int nout)
          Indicates whether this Transformer is able to transform between coordinate spaces with the given dimensionalities.
abstract  double[][] tran2(int npoint, double[] xin, double[] yin, boolean forward)
          Transforms points from 2-d input coordinates to 2-d output coordinates.
 double[][] tranP(int npoint, int ncoord_in, double[][] in, boolean forward, int ncoord_out)
          Transforms points from input coordinates to output coordinates.
 
Methods inherited from class uk.ac.starlink.ast.Transformer
getAuthor, getContact, getPurpose, hasForward, hasInverse, simpFI, simpIF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transformer2

public Transformer2()
Method Detail

canTransformCoords

public final boolean canTransformCoords(int nin,
                                        int nout)
Indicates whether this Transformer is able to transform between coordinate spaces with the given dimensionalities.

Specified by:
canTransformCoords in class Transformer
Parameters:
nin - the number of coordinates of an input point
nout - the number of coordinates of an output point
Returns:
true only if both nin and nout are equal to 2

tranP

public final double[][] tranP(int npoint,
                              int ncoord_in,
                              double[][] in,
                              boolean forward,
                              int ncoord_out)
                       throws Exception
Description copied from class: Transformer
Transforms points from input coordinates to output coordinates. This method does the work of the Transformer, taking an array of input coordinate arrays and returning an array of output coordinate arrays.

This method will only be called with forward set true if a prior call of the hasForward method has returned true, and will only be called with forward set false if a prior call of the hasInverse has returned true.

If forward is true, then this method will only be called with values of ncoord_in, ncoord_out for which a prior call of canTransform(ncoord_in,ncoord_out) has returned true.
If forward is false, then this method will only be called with values of ncoord_in, ncoord_out for which a prior call of canTransform(ncoord_out,ncoord_in) has returned true.

Specified by:
tranP in class Transformer
Parameters:
npoint - the number of points to be transformed
ncoord_in - the number of coordinates being supplied for each input point (the dimensionality of the input space)
in - an array of ncoord_in arrays, each containing npoint elements. These give the coordinates of each point to transform.
forward - true if the forward transformation is to be used, false if its inverse transformation is to be used
ncoord_out - the number of coordinates being generated by the transformation for each output point (the dimensionality of the output space). This need not be equal to ncoord_in.
Returns:
an array of ncoord_out arrays, each containing npoint elements. These give the coordinates of the transformed points. throws Exception If an error occurs during the transformation, this method may throw an Exception. In this case the transformation will be aborted.
Throws:
Exception

tran2

public abstract double[][] tran2(int npoint,
                                 double[] xin,
                                 double[] yin,
                                 boolean forward)
                          throws Exception
Transforms points from 2-d input coordinates to 2-d output coordinates. This method does the work of the Transformer2, taking input x and y coordinate arrays and returning a two-element array consisting of the x and y output coordinate arrays.

This method will only be called with forward set true if a prior call of the hasForward method has returned true, and will only be called with forward set false if a prior call of the hasInverse has returned true.

Parameters:
npoint - the number of points to be transformed
xin - an array of npoint elements representing the X coordinates to be transformed
yin - an array of npoint elements representing the Y coordinates to be transformed
forward - true if the forward transformation is to be used, false if its inverse transformation is to be used
Returns:
a two-element array; the first element is an npoint-element array of the output X coordinates, and the second element is an npoint-element array of the output Y coordinates
Throws:
Exception - If an error occurs during the transformation, this method may throw an Exception. In this case the transformation will be aborted.


Copyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.