? .snprj ? a ? classpath.proj ? libtool.m4 ? patch Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.1875 diff -c -p -u -r1.1875 ChangeLog --- ChangeLog 5 Feb 2004 19:54:47 -0000 1.1875 +++ ChangeLog 5 Feb 2004 22:03:45 -0000 @@ -1,3 +1,13 @@ +2004-02-05 Olga Rodimina + + * java/awt/geom/AffineTransform.java: + Corrected comments on the field definitions + for m11 and m10 + (shear): Fixed few errors that caused shear + transformation to be performed incorrectly. + (createInverse): Fixed to return correct inverse + of the given matrix. + 2004-02-05 Thomas Fitzsimmons * java/awt/Scrollbar.java (next_scrollbar_number): New field. Index: java/awt/geom/AffineTransform.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/geom/AffineTransform.java,v retrieving revision 1.5 diff -c -p -u -r1.5 AffineTransform.java --- java/awt/geom/AffineTransform.java 17 Sep 2003 19:44:26 -0000 1.5 +++ java/awt/geom/AffineTransform.java 5 Feb 2004 22:03:46 -0000 @@ -226,7 +226,7 @@ public class AffineTransform implements private double m00; /** - * The Y coordinate scaling element of the transform matrix. + * The Y coordinate shearing element of the transform matrix. * * @serial matrix[1,0] */ @@ -240,7 +240,7 @@ public class AffineTransform implements private double m01; /** - * The Y coordinate shearing element of the transform matrix. + * The Y coordinate scaling element of the transform matrix. * * @serial matrix[1,1] */ @@ -738,10 +738,10 @@ public class AffineTransform implements */ public void shear(double shx, double shy) { - double n00 = m00 + shx * m01; - double n01 = shx * m00 + m01; - double n10 = m10 * shy + m11; - double n11 = shx * m10 + m11; + double n00 = m00 + (shy * m01); + double n01 = m01 + (shx * m00); + double n10 = m10 + (shy * m11); + double n11 = m11 + (shx * m10); m00 = n00; m01 = n01; m10 = n10; @@ -996,6 +996,38 @@ public class AffineTransform implements * map multiple points to the same line or point). A transform exists only * if getDeterminant() has a non-zero value. * + * The inverse is calculated as: + * + *
+   *
+   * Let A be the matrix for which we want to find the inverse:
+   *
+   * A = [ m00 m01 m02 ]
+   *     [ m10 m11 m12 ]
+   *     [ 0   0   1   ] 
+   *
+   *
+   *                 1    
+   * inverse (A) =  ---   x  adjoint(A) 
+   *                det 
+   *
+   *
+   *
+   *             =   1       [  m11  -m01   m01*m12-m02*m11  ]
+   *                ---   x  [ -m10   m00  -m00*m12+m10*m02  ]
+   *                det      [  0     0     m00*m11-m10*m01  ]
+   *
+   *
+   *
+   *             = [  m11/det  -m01/det   m01*m12-m02*m11/det ]
+   *               [ -m10/det   m00/det  -m00*m12+m10*m02/det ]
+   *               [   0           0          1               ]
+   *
+   *
+   * 
+ * + * + * * @return a new inverse transform * @throws NoninvertibleTransformException if inversion is not possible * @see #getDeterminant() @@ -1006,8 +1038,15 @@ public class AffineTransform implements double det = getDeterminant(); if (det == 0) throw new NoninvertibleTransformException("can't invert transform"); - return new AffineTransform(m11 / det, -m10 / det, m01 / det, -m00 / det, - -m02, -m12); + + double im00 = m11 / det; + double im10 = -m10 / det; + double im01 = -m01 / det; + double im11 = m00 / det; + double im02 = (m01 * m12 - m02 * m11) / det; + double im12 = (-m00 * m12 + m10 * m02) / det; + + return new AffineTransform (im00, im10, im01, im11, im02, im12); } /**