Program: 194918
Project: 194918
Buggy source:
/** 
 * <p> Rotates the supplied rotation matrix so it is expressed in a different coordinate system. This is typically used when an application needs to compute the three orientation angles of the device (see  {@link #getOrientation}) in a different coordinate system. </p> <p> When the rotation matrix is used for drawing (for instance with OpenGL ES), it usually <b>doesn't need</b> to be transformed by this function, unless the screen is physically rotated, in which case you can use  {@link android.view.Display#getRotation() Display.getRotation()} toretrieve the current rotation of the screen. Note that because the user is generally free to rotate their screen, you often should consider the rotation in deciding the parameters to use here. </p> <p> <u>Examples:</u> <p> <ul> <li>Using the camera (Y axis along the camera's axis) for an augmented reality application where the rotation angles are needed:</li> <p> <ul> <code>remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR);</code> </ul> </p> <li>Using the device as a mechanical compass when rotation is {@link android.view.Surface#ROTATION_90 Surface.ROTATION_90}:</li> <p> <ul> <code>remapCoordinateSystem(inR, AXIS_Y, AXIS_MINUS_X, outR);</code> </ul> </p> Beware of the above example. This call is needed only to account for a rotation from its natural orientation when calculating the rotation angles (see   {@link #getOrientation}). If the rotation matrix is also used for rendering, it may not need to be transformed, for instance if your  {@link android.app.Activity Activity} is running in landscape mode.</ul> <p> Since the resulting coordinate system is orthonormal, only two axes need to be specified.
 * @param inR the rotation matrix to be transformed. Usually it is the matrix returned by  {@link #getRotationMatrix}.
 * @param X defines on which world axis and direction the X axis of the device is mapped.
 * @param Y defines on which world axis and direction the Y axis of the device is mapped.
 * @param outR the transformed rotation matrix. inR and outR should not be the same array.
 * @return <code>true</code> on success. <code>false</code> if the inputparameters are incorrect, for instance if X and Y define the same axis. Or if inR and outR don't have the same length.
 * @see #getRotationMatrix(float[],float[],float[],float[])
 */
public static boolean remapCoordinateSystem(float[] inR,int X,int Y,float[] outR){
  if (inR == outR) {
    final float[] temp=mTempMatrix;
synchronized (temp) {
      if (remapCoordinateSystemImpl(inR,X,Y,temp)) {
        final int size=outR.length;
        for (int i=0; i < size; i++)         outR[i]=temp[i];
        return true;
      }
    }
  }
  return remapCoordinateSystemImpl(inR,X,Y,outR);
}

Fixed version (ground truth):
/** 
 * <p> Rotates the supplied rotation matrix so it is expressed in a different coordinate system. This is typically used when an application needs to compute the three orientation angles of the device (see  {@link #getOrientation}) in a different coordinate system. </p> <p> When the rotation matrix is used for drawing (for instance with OpenGL ES), it usually <b>doesn't need</b> to be transformed by this function, unless the screen is physically rotated, in which case you can use  {@link android.view.Display#getRotation() Display.getRotation()} toretrieve the current rotation of the screen. Note that because the user is generally free to rotate their screen, you often should consider the rotation in deciding the parameters to use here. </p> <p> <u>Examples:</u> <p> <ul> <li>Using the camera (Y axis along the camera's axis) for an augmented reality application where the rotation angles are needed:</li> <p> <ul> <code>remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR);</code> </ul> </p> <li>Using the device as a mechanical compass when rotation is {@link android.view.Surface#ROTATION_90 Surface.ROTATION_90}:</li> <p> <ul> <code>remapCoordinateSystem(inR, AXIS_Y, AXIS_MINUS_X, outR);</code> </ul> </p> Beware of the above example. This call is needed only to account for a rotation from its natural orientation when calculating the rotation angles (see   {@link #getOrientation}). If the rotation matrix is also used for rendering, it may not need to be transformed, for instance if your  {@link android.app.Activity Activity} is running in landscape mode.</ul> <p> Since the resulting coordinate system is orthonormal, only two axes need to be specified.
 * @param inR the rotation matrix to be transformed. Usually it is the matrix returned by  {@link #getRotationMatrix}.
 * @param X defines the axis of the new cooridinate system that coincide with the X axis of the original coordinate system.
 * @param Y defines the axis of the new cooridinate system that coincide with the Y axis of the original coordinate system.
 * @param outR the transformed rotation matrix. inR and outR should not be the same array.
 * @return <code>true</code> on success. <code>false</code> if the inputparameters are incorrect, for instance if X and Y define the same axis. Or if inR and outR don't have the same length.
 * @see #getRotationMatrix(float[],float[],float[],float[])
 */
public static boolean remapCoordinateSystem(float[] inR,int X,int Y,float[] outR){
  if (inR == outR) {
    final float[] temp=mTempMatrix;
synchronized (temp) {
      if (remapCoordinateSystemImpl(inR,X,Y,temp)) {
        final int size=outR.length;
        for (int i=0; i < size; i++)         outR[i]=temp[i];
        return true;
      }
    }
  }
  return remapCoordinateSystemImpl(inR,X,Y,outR);
}