Loading...
Searching...
No Matches
casacore::LinearXform Class Reference
coordinates package (libcasa_coordinates) » Coordinates_module » Coordinates_module_internal_classes

More...

`#include <LinearXform.h>`

## Public Member Functions

| LinearXform (uInt naxis=1)
| Construct with specified number of axes.
| LinearXform (const Vector< Double > &crpix, const Vector< Double > &cdelt)
| Construct the linear transformation from the supplied reference pixel and increment.
| LinearXform (const Vector< Double > &crpix, const Vector< Double > &cdelt, const Matrix< Double > &pc)
| Construct a linear transformation, supplying all of the reference pixel, increment and PC matrix.
| LinearXform (const LinearXform &other)
| Copy constructor (copy sematics).
LinearXform & | operator= (const LinearXform &other)
| Assignment (copy sematics).
| ~LinearXform ()
| Destructor.
uInt | nWorldAxes () const
| Returns the number of world axes, which for this class is also the number of pixel axes.
Bool | forward (Vector< Double > &pixel, const Vector< Double > &world, String &errorMsg) const
| Convert world coordinates to pixel coordinates (forward), or pixel coordinates to world (reverse).
Bool | reverse (Vector< Double > &world, const Vector< Double > &pixel, String &errorMsg) const
Vector< Double > | crpix () const
| Retrieve the value of crpix, cdelt, and pc.
Vector< Double > | cdelt () const
Matrix< Double > | pc () const
void | crpix (const Vector< Double > &newvals)
| Set the value of crpix, cdelt, and pc.
void | cdelt (const Vector< Double > &newvals)
void | pc (const Matrix< Double > &newvals)
LinearXform * | fourierInvert (String &errMsg, const Vector< Bool > &axes, const Vector< Double > &crpix, const Vector< Double > &scale) const
| Invert the LinearXform ready for use in a Fourier Transformed Coordinate.
Bool | near (const LinearXform &other, Double tol=1e-6) const
| Comparison function.
Bool | near (const LinearXform &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const

## Private Member Functions

void | set_linprm ()

## Private Attributes

linprm | linprm_p
| A WCSLIB C-structure.
Bool | isPCDiagonal_p

## Detailed Description

Perform a linear transform between input and output vectors

### Intended use:

Internal

### Review Status

Reviewed By:
  Peter Barnes
Date Reviewed:
  1999/12/24
Test programs:
  tLinearXform

### Prerequisite

- General knowledge of Casacore Arrays
- Knowledge of FITS terminology in coordinate transformations

### Synopsis

This class represents the common linear part of a FITS coordinate transformation. In particular it does the following:

world = cdelt * PC * (pixel - crpix)
casacore::LinearXform::crpix
Vector< Double > crpix() const
Retrieve the value of crpix, cdelt, and pc.
casacore::LinearXform::cdelt
Vector< Double > cdelt() const

Where PC is an NxN matrix; pixel, crpix (reference pixel) and world are length N vectors; and cdelt (increment) is an NxN diagonal matrix, represented as a length N vector.

Normally this class isn't used directly, rather it is used indirectly through a class like LinearCoordinate.

The actual computations are performed by WCSLIB, written by Mark Calabretta of the ATNF.

### Example

Let's make a LinearXform housing two axes with a unit diagonal PC matrix and convert from pixel to world

Vector<Double> crpix(2), cdelt(2);
crpix(0) = 10.0; crpix(1) = 20.0;
cdelt(0) = 1.0; cdelt(1) = -1.0;
LinearXform lxf(crpix, cdelt);
String errMsg;
Vector<Double> world, pixel(2);
pixel = 10.0;
Bool ok = lxf.reverse(world, pixel, errMsg);
if (ok) {
cerr << "pixel, world = " << pixel << world << endl;
} else {
cerr << "Error : " << errMsg << endl;
}
casacore::LinearXform::LinearXform
LinearXform(uInt naxis=1)
Construct with specified number of axes.
casacore::String
String: the storage and methods of handling collections of characters.
Definition String.h:223
casacore::Vector
Definition Vector.h:82
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40

The answer should be a world vector with values 0 and -10.

### Motivation

Factor out the common linear part of coordinate transformations.

### Thrown Exceptions

- AipsError

### To Do

- Allow different numbers of pixel and world axes.

Definition at line 106 of file LinearXform.h.

## Constructor & Destructor Documentation

## LinearXform() [1/4]

casacore::LinearXform::LinearXform | ( | uInt | naxis = 1 | ) |

Construct with specified number of axes.

The reference pixel is assumed to be 0, and the increment is assumed to be unity, and the PC matrix is assumed to be diagonal.

Referenced by fourierInvert(), LinearXform(), near(), near(), and operator=().

## LinearXform() [2/4]

casacore::LinearXform::LinearXform | ( | const Vector< Double > & | crpix,
|  | const Vector< Double > & | cdelt )

Construct the linear transformation from the supplied reference pixel and increment.

The PC matrix is the unit matrix. crpix and cdelt must have the same number of elements.

References cdelt(), and crpix().

## LinearXform() [3/4]

casacore::LinearXform::LinearXform | ( | const Vector< Double > & | crpix,
|  | const Vector< Double > & | cdelt,
|  | const Matrix< Double > & | pc )

Construct a linear transformation, supplying all of the reference pixel, increment and PC matrix.

The vectors must be of the same length ("n") and the number of rows and columns in the matrix must also be n.

References cdelt(), crpix(), and pc().

## LinearXform() [4/4]

casacore::LinearXform::LinearXform | ( | const LinearXform & | other | ) |

Copy constructor (copy sematics).

References LinearXform().

## ~LinearXform()

casacore::LinearXform::~LinearXform | ( |  | ) |

Destructor.

## Member Function Documentation

## cdelt() [1/2]

Vector< Double > casacore::LinearXform::cdelt | ( |  | ) | const

Referenced by LinearXform(), and LinearXform().

## cdelt() [2/2]

void casacore::LinearXform::cdelt | ( | const Vector< Double > & | newvals | ) |

## crpix() [1/2]

Vector< Double > casacore::LinearXform::crpix | ( |  | ) | const

Retrieve the value of crpix, cdelt, and pc.

Referenced by fourierInvert(), LinearXform(), and LinearXform().

## crpix() [2/2]

void casacore::LinearXform::crpix | ( | const Vector< Double > & | newvals | ) |

Set the value of crpix, cdelt, and pc.

Note that since you can only set one of them, you cannot change the dimensionality of the transform using these functions. Instead use assignment on a temporary, i.e.: linxform = LinearXform (crpix,crval,pc);

## forward()

Bool casacore::LinearXform::forward | ( | Vector< Double > & | pixel,
|  | const Vector< Double > & | world,
|  | String & | errorMsg ) const

Convert world coordinates to pixel coordinates (forward), or pixel coordinates to world (reverse).

If the conversion works True is returned, otherwise False is returned and errorMsg is set. The output vectors are resized appropriately.

## fourierInvert()

LinearXform * casacore::LinearXform::fourierInvert | ( | String & | errMsg,
|  | const Vector< Bool > & | axes,
|  | const Vector< Double > & | crpix,
|  | const Vector< Double > & | scale ) const

Invert the LinearXform ready for use in a Fourier Transformed Coordinate.

It is the callers responsibility to delete the pointer. If it fails the pointer is 0 and an error message is provided

References crpix(), and LinearXform().

## near() [1/2]

Bool casacore::LinearXform::near | ( | const LinearXform & | other,
|  | const Vector< Int > & | excludeAxes,
|  | Double | tol = 1e-6 ) const

References LinearXform().

## near() [2/2]

Bool casacore::LinearXform::near | ( | const LinearXform & | other,
|  | Double | tol = 1e-6 ) const

Comparison function.

Any private Double data members are compared with the specified fractional tolerance. You can specify axes to exclude from the comparison if you wish.

References LinearXform().

## nWorldAxes()

uInt casacore::LinearXform::nWorldAxes | ( |  | ) | const

Returns the number of world axes, which for this class is also the number of pixel axes.

## operator=()

LinearXform & casacore::LinearXform::operator= | ( | const LinearXform & | other | ) |

Assignment (copy sematics).

References LinearXform().

## pc() [1/2]

Matrix< Double > casacore::LinearXform::pc | ( |  | ) | const

Referenced by LinearXform().

## pc() [2/2]

void casacore::LinearXform::pc | ( | const Matrix< Double > & | newvals | ) |

## reverse()

Bool casacore::LinearXform::reverse | ( | Vector< Double > & | world,
|  | const Vector< Double > & | pixel,
|  | String & | errorMsg ) const

## set_linprm()

void casacore::LinearXform::set_linprm | ( |  | ) |

private

## Member Data Documentation

## isPCDiagonal_p

Bool casacore::LinearXform::isPCDiagonal_p

private

Definition at line 190 of file LinearXform.h.

## linprm_p

linprm casacore::LinearXform::linprm_p

mutable private

A WCSLIB C-structure.

Definition at line 188 of file LinearXform.h.

The documentation for this class was generated from the following file:

- coordinates/Coordinates/LinearXform.h