Tabnine Logo
Matrix2
Code IndexAdd Tabnine to your IDE (free)

How to use
Matrix2
in
org.apache.sis.referencing.operation.matrix

Best Java code snippets using org.apache.sis.referencing.operation.matrix.Matrix2 (Showing top 20 results out of 315)

origin: org.apache.sis.core/sis-referencing

/**
 * Returns this transform as an affine transform matrix.
 */
@Override
public Matrix getMatrix() {
  return new Matrix2(scale, offset, 0, 1);
}
origin: org.apache.sis.core/sis-referencing

/**
 * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
 * The array length is 4.
 *
 * @return {@inheritDoc}
 */
@Override
public final double[] getElements() {
  final double[] elements = new double[SIZE*SIZE];
  getElements(elements);
  return elements;
}
origin: org.apache.sis.core/sis-referencing

/**
 * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
 * The array length shall be 4.
 */
@Override
public final void setElements(final double[] elements) {
  ensureLengthMatch(SIZE*SIZE, elements);
  m00 = elements[0];    m01 = elements[1];
  m10 = elements[2];    m11 = elements[3];
}
origin: org.apache.sis.core/sis-referencing

/**
 * Casts or copies the given matrix to a {@code Matrix2} implementation. If the given {@code matrix}
 * is already an instance of {@code Matrix2}, then it is returned unchanged. Otherwise this method
 * verifies the matrix size, then copies all elements in a new {@code Matrix2} object.
 *
 * @param  matrix  the matrix to cast or copy, or {@code null}.
 * @return the matrix argument if it can be safely casted (including {@code null} argument),
 *         or a copy of the given matrix otherwise.
 * @throws MismatchedMatrixSizeException if the size of the given matrix is not {@value #SIZE}×{@value #SIZE}.
 */
public static Matrix2 castOrCopy(final Matrix matrix) throws MismatchedMatrixSizeException {
  if (matrix == null || matrix instanceof Matrix2) {
    return (Matrix2) matrix;
  }
  ensureSizeMatch(SIZE, SIZE, matrix);
  return new Matrix2(matrix);
}
origin: apache/sis

/**
 * Tests the {@link Matrix2#Matrix2(double, double, double, double)} constructor.
 * This constructor is specific to the implementation class.
 */
@Test
public void testConstructor() {
  initialize(-8453835559080304420L);
  final double[] elements = createRandomPositiveValues(SIZE * SIZE);
  final Matrix2 matrix = new Matrix2(
      elements[0],
      elements[1],
      elements[2],
      elements[3]);
  validate(matrix);
  assertArrayEquals(elements, matrix.getElements(), STRICT);
}
origin: org.apache.sis.core/sis-referencing

/**
 * Retrieves the value at the specified row and column of this matrix.
 * This method can be invoked when the matrix size or type is unknown.
 * If the matrix is known to be an instance of {@code Matrix2},
 * then the {@link #m00} … {@link #m11} fields can be read directly for efficiency.
 *
 * @param  row     the row index, which can only be 0 or 1.
 * @param  column  the column index, which can only be 0 or 1.
 * @return the current value at the given row and column.
 */
@Override
public final double getElement(final int row, final int column) {
  if (row >= 0 && row < SIZE && column >= 0 && column < SIZE) {
    switch (row*SIZE + column) {
      case 0: return m00;
      case 1: return m01;
      case 2: return m10;
      case 3: return m11;
    }
  }
  throw indexOutOfBounds(row, column);
}
origin: org.apache.sis.core/sis-referencing

/**
 * Creates a new matrix initialized to the specified values.
 * The length of the given array must be 4 and the values in the same order than the above constructor.
 *
 * @param  elements  elements of the matrix. Column indices vary fastest.
 * @throws IllegalArgumentException if the given array does not have the expected length.
 *
 * @see #setElements(double[])
 * @see Matrices#create(int, int, double[])
 */
public Matrix2(final double[] elements) throws IllegalArgumentException {
  setElements(elements);
}
origin: apache/sis

/**
 * Casts or copies the given matrix to a {@code Matrix2} implementation. If the given {@code matrix}
 * is already an instance of {@code Matrix2}, then it is returned unchanged. Otherwise this method
 * verifies the matrix size, then copies all elements in a new {@code Matrix2} object.
 *
 * @param  matrix  the matrix to cast or copy, or {@code null}.
 * @return the matrix argument if it can be safely casted (including {@code null} argument),
 *         or a copy of the given matrix otherwise.
 * @throws MismatchedMatrixSizeException if the size of the given matrix is not {@value #SIZE}×{@value #SIZE}.
 */
public static Matrix2 castOrCopy(final Matrix matrix) throws MismatchedMatrixSizeException {
  if (matrix == null || matrix instanceof Matrix2) {
    return (Matrix2) matrix;
  }
  ensureSizeMatch(SIZE, SIZE, matrix);
  return new Matrix2(matrix);
}
origin: apache/sis

/**
 * Retrieves the value at the specified row and column of this matrix.
 * This method can be invoked when the matrix size or type is unknown.
 * If the matrix is known to be an instance of {@code Matrix2},
 * then the {@link #m00} … {@link #m11} fields can be read directly for efficiency.
 *
 * @param  row     the row index, which can only be 0 or 1.
 * @param  column  the column index, which can only be 0 or 1.
 * @return the current value at the given row and column.
 */
@Override
public final double getElement(final int row, final int column) {
  if (row >= 0 && row < SIZE && column >= 0 && column < SIZE) {
    switch (row*SIZE + column) {
      case 0: return m00;
      case 1: return m01;
      case 2: return m10;
      case 3: return m11;
    }
  }
  throw indexOutOfBounds(row, column);
}
origin: apache/sis

/**
 * Creates a new matrix initialized to the specified values.
 * The length of the given array must be 4 and the values in the same order than the above constructor.
 *
 * @param  elements  elements of the matrix. Column indices vary fastest.
 * @throws IllegalArgumentException if the given array does not have the expected length.
 *
 * @see #setElements(double[])
 * @see Matrices#create(int, int, double[])
 */
public Matrix2(final double[] elements) throws IllegalArgumentException {
  setElements(elements);
}
origin: apache/sis

/**
 * Returns this transform as an affine transform matrix.
 */
@Override
public Matrix getMatrix() {
  return new Matrix2(scale, offset, 0, 1);
}
origin: apache/sis

/**
 * Returns all matrix elements in a flat, row-major (column indices vary fastest) array.
 * The array length is 4.
 *
 * @return {@inheritDoc}
 */
@Override
public final double[] getElements() {
  final double[] elements = new double[SIZE*SIZE];
  getElements(elements);
  return elements;
}
origin: org.apache.sis.core/sis-referencing

/**
 * Modifies the value at the specified row and column of this matrix.
 * This method can be invoked when the matrix size or type is unknown.
 * If the matrix is known to be an instance of {@code Matrix2},
 * then the {@link #m00} … {@link #m11} fields can be set directly for efficiency.
 *
 * @param  row     the row index, which can only be 0 or 1.
 * @param  column  the column index, which can only be 0 or 1.
 * @param  value   the new value to set at the given row and column.
 */
@Override
public final void setElement(final int row, final int column, final double value) {
  if (row >= 0 && row < SIZE && column >= 0 && column < SIZE) {
    switch (row*SIZE + column) {
      case 0: m00 = value; return;
      case 1: m01 = value; return;
      case 2: m10 = value; return;
      case 3: m11 = value; return;
    }
  }
  throw indexOutOfBounds(row, column);
}
origin: apache/sis

/**
 * Sets all matrix elements from a flat, row-major (column indices vary fastest) array.
 * The array length shall be 4.
 */
@Override
public final void setElements(final double[] elements) {
  ensureLengthMatch(SIZE*SIZE, elements);
  m00 = elements[0];    m01 = elements[1];
  m10 = elements[2];    m11 = elements[3];
}
origin: org.apache.sis.core/sis-referencing

/**
 * {@inheritDoc}
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff,
            final double[] dstPts, final int dstOff,
            final boolean derivate) throws ProjectionException
{
  final double φ = srcPts[srcOff+1];
  if (dstPts != null) {
    dstPts[dstOff  ] = srcPts[srcOff];
    dstPts[dstOff+1] = sin(φ);
  }
  return derivate ? new Matrix2(1, 0, 0, cos(φ)) : null;
}
origin: apache/sis

/**
 * Modifies the value at the specified row and column of this matrix.
 * This method can be invoked when the matrix size or type is unknown.
 * If the matrix is known to be an instance of {@code Matrix2},
 * then the {@link #m00} … {@link #m11} fields can be set directly for efficiency.
 *
 * @param  row     the row index, which can only be 0 or 1.
 * @param  column  the column index, which can only be 0 or 1.
 * @param  value   the new value to set at the given row and column.
 */
@Override
public final void setElement(final int row, final int column, final double value) {
  if (row >= 0 && row < SIZE && column >= 0 && column < SIZE) {
    switch (row*SIZE + column) {
      case 0: m00 = value; return;
      case 1: m01 = value; return;
      case 2: m10 = value; return;
      case 3: m11 = value; return;
    }
  }
  throw indexOutOfBounds(row, column);
}
origin: apache/sis

/**
 * {@inheritDoc}
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff,
            final double[] dstPts, final int dstOff,
            final boolean derivate) throws ProjectionException
{
  final double φ = srcPts[srcOff+1];
  if (dstPts != null) {
    dstPts[dstOff  ] = srcPts[srcOff];
    dstPts[dstOff+1] = sin(φ);
  }
  return derivate ? new Matrix2(1, 0, 0, cos(φ)) : null;
}
origin: org.apache.sis.core/sis-referencing

/**
 * Converts a single coordinate and optionally computes the derivative.
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff,
            final double[] dstPts, final int dstOff,
            final boolean derivate)
{
  final double r = srcPts[srcOff  ];
  final double θ = srcPts[srcOff+1];
  final double cosθ = cos(θ);
  final double sinθ = sin(θ);
  if (dstPts != null) {
    dstPts[dstOff  ] = r*cosθ;
    dstPts[dstOff+1] = r*sinθ;
  }
  if (!derivate) {
    return null;
  }
  return new Matrix2(cosθ, -r*sinθ,
            sinθ,  r*cosθ);
}
origin: apache/sis

/**
 * Converts a single coordinate and optionally computes the derivative.
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff,
            final double[] dstPts, final int dstOff,
            final boolean derivate)
{
  final double x  = srcPts[srcOff  ];
  final double y  = srcPts[srcOff+1];
  final double r  = hypot(x, y);
  if (dstPts != null) {
    dstPts[dstOff  ] = r;
    dstPts[dstOff+1] = atan2(y, x);
  }
  if (!derivate) {
    return null;
  }
  final double r2 = r*r;
  return new Matrix2(x/r,   y/r,
           -y/r2,  x/r2);
}
origin: apache/sis

/**
 * Converts a single coordinate and optionally computes the derivative.
 */
@Override
public Matrix transform(final double[] srcPts, final int srcOff,
            final double[] dstPts, final int dstOff,
            final boolean derivate)
{
  final double r = srcPts[srcOff  ];
  final double θ = srcPts[srcOff+1];
  final double cosθ = cos(θ);
  final double sinθ = sin(θ);
  if (dstPts != null) {
    dstPts[dstOff  ] = r*cosθ;
    dstPts[dstOff+1] = r*sinθ;
  }
  if (!derivate) {
    return null;
  }
  return new Matrix2(cosθ, -r*sinθ,
            sinθ,  r*cosθ);
}
org.apache.sis.referencing.operation.matrixMatrix2

Javadoc

A matrix of fixed #SIZE× #SIZE size, typically resulting from org.opengis.referencing.operation.MathTransform2D derivative computation. The matrix members are:
 ┌         ┐ 
│  
#m00  
#m01 │ 
│  
#m10  
#m11 │ 
└         ┘

Most used methods

  • <init>
    Creates a new matrix initialized to the specified values. The length of the given array must be 4 an
  • getElements
    Copies the matrix elements in the given flat array. The array length shall be at least 4, may also b
  • ensureLengthMatch
  • ensureSizeMatch
  • indexOutOfBounds
  • setElements
    Sets all matrix elements from a flat, row-major (column indices vary fastest) array. The array lengt

Popular in Java

  • Start an intent from android
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • compareTo (BigDecimal)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now