@@ -124,25 +124,17 @@ public static double getVoxelScreenSize( final AffineTransform3D screenTransform
124124 */
125125 public static double [] getPixelSourceSize ( final AffineTransform3D screenTransform , final Source < ? > source , final int timepoint , final int mipmapIndex )
126126 {
127+ final AffineTransform3D t = new AffineTransform3D ();
128+ source .getSourceTransform ( timepoint , mipmapIndex , t );
129+ t .preConcatenate ( screenTransform );
130+ final AffineTransform3D screenToSource = t .inverse ();
127131 final double [] sourcePixelSize = new double [ 2 ];
128- final AffineTransform3D sourceToScreen = new AffineTransform3D ();
129- sourceToScreen .set ( screenTransform );
130- final AffineTransform3D sourceTransform = new AffineTransform3D ();
131- source .getSourceTransform ( timepoint , mipmapIndex , sourceTransform );
132- sourceToScreen .concatenate ( sourceTransform );
133- final double [] zero = new double [] { 0 , 0 , 0 };
134- final double [] tzero = new double [ 3 ];
135- final double [] one = new double [ 3 ];
136- final double [] tone = new double [ 3 ];
137- final double [] diff = new double [ 3 ];
138- sourceToScreen .applyInverse ( tzero , zero );
139- for ( int i = 0 ; i < 2 ; ++i )
132+ final double [] tmp = new double [ 3 ];
133+ for ( int d = 0 ; d < 2 ; ++d )
140134 {
141- for ( int d = 0 ; d < 3 ; ++d )
142- one [ d ] = d == i ? 1 : 0 ;
143- sourceToScreen .applyInverse ( tone , one );
144- LinAlgHelpers .subtract ( tone , tzero , diff );
145- sourcePixelSize [ i ] = LinAlgHelpers .length ( diff );
135+ for ( int i = 0 ; i < 3 ; ++i )
136+ tmp [ i ] = screenToSource .get ( i , d );
137+ sourcePixelSize [ d ] = LinAlgHelpers .length ( tmp );
146138 }
147139 return sourcePixelSize ;
148140 }
0 commit comments