/* * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2005-2008, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotools.referencing.operation.matrix; import javax.vecmath.Matrix3d; import java.awt.geom.AffineTransform; import org.opengis.referencing.operation.Matrix; import org.geotools.resources.i18n.Errors; import org.geotools.resources.i18n.ErrorKeys; /** * A matrix of fixed {@value #SIZE}×{@value #SIZE} size. This specialized matrix provides * better accuracy than {@link GeneralMatrix} for matrix inversion and multiplication. * * @since 2.2 * * * @source $URL$ * @version $Id$ * @author Martin Desruisseaux (IRD) */ public class Matrix3 extends Matrix3d implements XMatrix { /** * Serial number for interoperability with different versions. */ private static final long serialVersionUID = 8902061778871586611L; /** * The matrix size, which is {@value}. */ public static final int SIZE = 3; /** * Creates a new identity matrix. */ public Matrix3() { setIdentity(); } /** * Creates a new matrix initialized to the specified values. */ public Matrix3(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) { super(m00, m01, m02, m10, m11, m12, m20, m21, m22); } /** * Constructs a 3×3 matrix from the specified affine transform. */ public Matrix3(final AffineTransform transform) { setMatrix(transform); } /** * Creates a new matrix initialized to the same value than the specified one. * The specified matrix size must be {@value #SIZE}×{@value #SIZE}. */ public Matrix3(final Matrix matrix) { if (matrix.getNumRow()!=SIZE || matrix.getNumCol()!=SIZE) { throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_MATRIX_SIZE)); } for (int j=0; j