org.geotools.referencing.operation
package.
*/
final class MatrixTransform extends AbstractMathTransform implements LinearTransform, Serializable {
/**
* Serial number for interoperability with different versions.
*/
private static final long serialVersionUID = -2104496465933824935L;
/**
* The number of rows.
*/
private final int numRow;
/**
* The number of columns.
*/
private final int numCol;
/**
* Elements of the matrix. Column indice vary fastest.
*/
private final double[] elt;
/**
* Construct a transform.
*/
protected MatrixTransform(final GMatrix matrix) {
numRow = matrix.getNumRow();
numCol = matrix.getNumCol();
elt = new double[numRow*numCol];
int index = 0;
for (int j=0; jsrcOff
) in the order
* [x0, y0, z0,
* x1, y1, z1...,
* xn, yn, zn]
.
*
* The transformed points (x',y',z')
are computed as below
* (note that this computation is similar to {@link PerspectiveTransform}):
*
* * * @param srcPts The array containing the source point coordinates. * @param srcOff The offset to the first point to be transformed in the source array. * @param dstPts The array into which the transformed point coordinates are returned. * @param dstOff The offset to the location of the first transformed point that is stored * in the destination array. The source and destination array sections can * be overlaps. * @param numPts The number of points to be transformed */ public void transform(float[] srcPts, int srcOff, final float[] dstPts, int dstOff, int numPts) { final int inputDimension = numCol-1; // The last ordinate will be assumed equals to 1. final int outputDimension = numRow-1; final double[] buffer = new double[numRow]; if (srcPts==dstPts) { // We are going to write in the source array. Checks if // source and destination sections are going to clash. final int upperSrc = srcOff + numPts*inputDimension; if (upperSrc > dstOff) { if (inputDimension >= outputDimension ? dstOff > srcOff : dstOff + numPts*outputDimension > upperSrc) { // If source overlaps destination, then the easiest workaround is // to copy source data. This is not the most efficient however... srcPts = new float[numPts*inputDimension]; System.arraycopy(dstPts, srcOff, srcPts, 0, srcPts.length); srcOff = 0; } } } while (--numPts>=0) { int mix=0; for (int j=0; j* [ u ] [ m00 m01 m02 m03 ] [ x ] * [ v ] = [ m10 m11 m12 m13 ] [ y ] * [ w ] [ m20 m21 m22 m23 ] [ z ] * [ t ] [ m30 m31 m32 m33 ] [ 1 ] * * x' = u/t * y' = v/t * y' = w/t *
srcOff
) in the order
* [x0, y0, z0,
* x1, y1, z1...,
* xn, yn, zn]
.
*
* The transformed points (x',y',z')
are computed as below
* (note that this computation is similar to {@link PerspectiveTransform}):
*
* * * @param srcPts The array containing the source point coordinates. * @param srcOff The offset to the first point to be transformed in the source array. * @param dstPts The array into which the transformed point coordinates are returned. * @param dstOff The offset to the location of the first transformed point that is stored * in the destination array. The source and destination array sections can * be overlaps. * @param numPts The number of points to be transformed */ public void transform(double[] srcPts, int srcOff, final double[] dstPts, int dstOff, int numPts) { final int inputDimension = numCol-1; // The last ordinate will be assumed equals to 1. final int outputDimension = numRow-1; final double[] buffer = new double[numRow]; if (srcPts==dstPts) { // We are going to write in the source array. Checks if // source and destination sections are going to clash. final int upperSrc = srcOff + numPts*inputDimension; if (upperSrc > dstOff) { if (inputDimension >= outputDimension ? dstOff > srcOff : dstOff + numPts*outputDimension > upperSrc) { // If source overlaps destination, then the easiest workaround is // to copy source data. This is not the most efficient however... srcPts = new double[numPts*inputDimension]; System.arraycopy(dstPts, srcOff, srcPts, 0, srcPts.length); srcOff = 0; } } } while (--numPts>=0) { int mix=0; for (int j=0; j* [ u ] [ m00 m01 m02 m03 ] [ x ] * [ v ] = [ m10 m11 m12 m13 ] [ y ] * [ w ] [ m20 m21 m22 m23 ] [ z ] * [ t ] [ m30 m31 m32 m33 ] [ 1 ] * * x' = u/t * y' = v/t * y' = w/t *