commit faa3aed0c622c78a8a78e17af795414c9021b166
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Aug 10 19:01:44 2020 +0100

    Introduce separate ROT_AXIS and FACE_AXIS ( step 2 )

diff --git a/src/main/java/org/distorted/main/RubikSurfaceView.java b/src/main/java/org/distorted/main/RubikSurfaceView.java
index 2ddf8a57..df236b74 100644
--- a/src/main/java/org/distorted/main/RubikSurfaceView.java
+++ b/src/main/java/org/distorted/main/RubikSurfaceView.java
@@ -34,7 +34,7 @@ import org.distorted.library.type.Static2D;
 import org.distorted.library.type.Static3D;
 import org.distorted.library.type.Static4D;
 import org.distorted.objects.RubikObject;
-import org.distorted.objects.RubikMovementObject;
+import org.distorted.objects.RubikMovement;
 import org.distorted.solvers.SolverMain;
 import org.distorted.states.RubikState;
 import org.distorted.states.RubikStatePlay;
@@ -71,7 +71,7 @@ public class RubikSurfaceView extends GLSurfaceView
 
     private RubikRenderer mRenderer;
     private RubikPreRender mPreRender;
-    private RubikMovementObject mMovement;
+    private RubikMovement mMovement;
     private boolean mDragging, mBeginningRotation, mContinuingRotation;
     private int mScreenWidth, mScreenHeight, mScreenMin;
 
@@ -140,7 +140,7 @@ public class RubikSurfaceView extends GLSurfaceView
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    void setMovement(RubikMovementObject movement)
+    void setMovement(RubikMovement movement)
       {
       mMovement = movement;
       }
diff --git a/src/main/java/org/distorted/objects/RubikCube.java b/src/main/java/org/distorted/objects/RubikCube.java
index 25f0e1c8..7ac695eb 100644
--- a/src/main/java/org/distorted/objects/RubikCube.java
+++ b/src/main/java/org/distorted/objects/RubikCube.java
@@ -53,9 +53,9 @@ class RubikCube extends RubikObject
   // the six axis that determine the faces
   static final Static3D[] FACE_AXIS = new Static3D[]
          {
-           new Static3D(1,0,0), new Static3D(-1,0,0),
-           new Static3D(0,1,0), new Static3D(0,-1,0),
-           new Static3D(0,0,1), new Static3D(0,0,-1)
+           new Static3D(-1,0,0), new Static3D(1,0,0),
+           new Static3D(0,-1,0), new Static3D(0,1,0),
+           new Static3D(0,0,-1), new Static3D(0,0,1)
          };
 
   private static final int[] FACE_COLORS = new int[]
diff --git a/src/main/java/org/distorted/objects/RubikMovement.java b/src/main/java/org/distorted/objects/RubikMovement.java
new file mode 100644
index 00000000..d8d0f9be
--- /dev/null
+++ b/src/main/java/org/distorted/objects/RubikMovement.java
@@ -0,0 +1,293 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2020 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube is free software: you can redistribute it and/or modify                            //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Magic Cube 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 General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.objects;
+
+import org.distorted.library.type.Static2D;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public abstract class RubikMovement
+  {
+  private int mLastTouchedAxis;
+  private float[] mPoint, mCamera, mTouch;
+  private float[] mPoint2D, mMove2D;
+  private float[][][] mCastAxis;
+  private int mNumRotAxis, mNumFaceAxis;
+  private float mDistanceCenterFace3D, mDistanceCenterFace2D;
+  private Static3D[] mFaceAxis;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  abstract boolean isInsideFace(float[] point);
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  RubikMovement(Static3D[] rotAxis, Static3D[] faceAxis, float distance3D, float distance2D)
+    {
+    mPoint = new float[3];
+    mCamera= new float[3];
+    mTouch = new float[3];
+
+    mPoint2D = new float[2];
+    mMove2D  = new float[2];
+
+    mNumRotAxis = rotAxis.length;
+    mFaceAxis   = faceAxis;
+    mNumFaceAxis= mFaceAxis.length;
+
+    mDistanceCenterFace3D = distance3D; // distance from the center of the object to each of its faces
+    mDistanceCenterFace2D = distance2D; // distance from the center of a face to its edge
+
+    // mCastAxis[1][2]{0,1} are the 2D coords of the 2nd axis cast onto the face defined by the
+    // 1st pair (axis,lr)
+    mCastAxis = new float[mNumFaceAxis][mNumRotAxis][2];
+
+    for( int casted=0; casted<mNumRotAxis; casted++)
+      {
+      Static3D a = rotAxis[casted];
+      mPoint[0]= a.get0();
+      mPoint[1]= a.get1();
+      mPoint[2]= a.get2();
+
+      for( int face=0; face<mNumFaceAxis; face++)
+        {
+        convertTo2Dcoords( mPoint, mFaceAxis[face], mCastAxis[face][casted]);
+        normalize2D(mCastAxis[face][casted]);
+        }
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void normalize2D(float[] vect)
+    {
+    float len = (float)Math.sqrt(vect[0]*vect[0] + vect[1]*vect[1]);
+    vect[0] /= len;
+    vect[1] /= len;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// find the casted axis with which our move2D vector forms an angle closest to 90 deg.
+
+  private int computeRotationIndex(int faceAxis, float[] move2D)
+    {
+    float cosAngle, minCosAngle = Float.MAX_VALUE;
+    int minIndex=-1;
+    float m0 = move2D[0];
+    float m1 = move2D[1];
+    float len = (float)Math.sqrt(m0*m0 + m1*m1);
+    float x,y;
+
+    if( len!=0.0f )
+      {
+      m0 /= len;
+      m1 /= len;
+      }
+    else
+      {
+      m0 = 1.0f;  // arbitrarily
+      m1 = 0.0f;  //
+      }
+
+    for(int rotAxis=0; rotAxis<mNumRotAxis; rotAxis++)
+      {
+      x = mCastAxis[faceAxis][rotAxis][0];
+      y = mCastAxis[faceAxis][rotAxis][1];
+
+      if( x*x + y*y > 0.01f )
+        {
+        cosAngle = m0*x + m1*y;
+        if( cosAngle<0 ) cosAngle = -cosAngle;
+
+        if( cosAngle<minCosAngle )
+          {
+          minCosAngle=cosAngle;
+          minIndex = rotAxis;
+          }
+        }
+      }
+
+    return minIndex;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private float computeOffset(float[] point, float[] axis)
+    {
+    return point[0]*axis[0] + point[1]*axis[1] + mDistanceCenterFace2D;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private boolean faceIsVisible(Static3D faceAxis)
+    {
+    float castCameraOnAxis = mCamera[0]*faceAxis.get0() + mCamera[1]*faceAxis.get1() + mCamera[2]*faceAxis.get2();
+    return castCameraOnAxis > mDistanceCenterFace3D;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// given precomputed mCamera and mPoint, respectively camera and touch point positions in ScreenSpace,
+// compute point 'output[]' which:
+// 1) lies on a face of the Object, i.e. surface defined by (axis, distance from (0,0,0)) [and this
+//    distance is +-mDistanceCenterFace, depending if it is the face on the left or the right end of
+//    the axis] (lr=0 or 1, so (2lr-1)*mDistanceCenterFace)
+// 2) is co-linear with mCamera and mPoint
+//
+// output = camera + alpha*(point-camera), where alpha = [dist-axis*camera] / [axis*(point-camera)]
+
+  private void castTouchPointOntoFace(Static3D faceAxis, float[] output)
+    {
+    float d0 = mPoint[0]-mCamera[0];
+    float d1 = mPoint[1]-mCamera[1];
+    float d2 = mPoint[2]-mCamera[2];
+    float a0 = faceAxis.get0();
+    float a1 = faceAxis.get1();
+    float a2 = faceAxis.get2();
+
+    float denom = a0*d0 + a1*d1 + a2*d2;
+
+    if( denom != 0.0f )
+      {
+      float axisCam = a0*mCamera[0] + a1*mCamera[1] + a2*mCamera[2];
+      float distance = mDistanceCenterFace3D;
+      float alpha = (distance-axisCam)/denom;
+
+      output[0] = mCamera[0] + d0*alpha;
+      output[1] = mCamera[1] + d1*alpha;
+      output[2] = mCamera[2] + d2*alpha;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Convert the 3D point3D into a 2D point on the same face surface, but in a different
+// coordinate system: a in-plane 2D coord where the origin is in the point where the axis intersects
+// the surface, and whose Y axis points 'north' i.e. is in the plane given by the 3D origin, the
+// original 3D Y axis and our 2D in-plane origin.
+// If those 3 points constitute a degenerate triangle which does not define a plane - which can only
+// happen if axis is vertical (or in theory when 2D origin and 3D origin meet, but that would have to
+// mean that the distance between the center of the Object and its faces is 0) - then we arbitrarily
+// decide that 2D Y = (0,0,-1) in the North Pole and (0,0,1) in the South Pole)
+
+  private void convertTo2Dcoords(float[] point3D, Static3D faceAxis, float[] output)
+    {
+    float y0,y1,y2; // base Y vector of the 2D coord system
+    float a0 = faceAxis.get0();
+    float a1 = faceAxis.get1();
+    float a2 = faceAxis.get2();
+
+    if( a0==0.0f && a2==0.0f )
+      {
+      y0=0; y1=0; y2=-a1;
+      }
+    else if( a1==0.0f )
+      {
+      y0=0; y1=1; y2=0;
+      }
+    else
+      {
+      float norm = (float)(-a1/Math.sqrt(1-a1*a1));
+      y0 = norm*a0; y1= norm*(a1-1/a1); y2=norm*a2;
+      }
+
+    float x0 = y1*a2 - y2*a1;  //
+    float x1 = y2*a0 - y0*a2;  // (2D coord baseY) x (axis) = 2D coord baseX
+    float x2 = y0*a1 - y1*a0;  //
+
+    float originAlpha = point3D[0]*a0 + point3D[1]*a1 + point3D[2]*a2;
+
+    float origin0 = originAlpha*a0; // coords of the point where axis
+    float origin1 = originAlpha*a1; // intersects surface plane i.e.
+    float origin2 = originAlpha*a2; // the origin of our 2D coord system
+
+    float v0 = point3D[0] - origin0;
+    float v1 = point3D[1] - origin1;
+    float v2 = point3D[2] - origin2;
+
+    output[0] = v0*x0 + v1*x1 + v2*x2;
+    output[1] = v0*y0 + v1*y1 + v2*y2;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
+    {
+    float objectRatio = RubikObject.getObjectRatio();
+
+    mPoint[0]  = rotatedTouchPoint.get0()/objectRatio;
+    mPoint[1]  = rotatedTouchPoint.get1()/objectRatio;
+    mPoint[2]  = rotatedTouchPoint.get2()/objectRatio;
+
+    mCamera[0] = rotatedCamera.get0()/objectRatio;
+    mCamera[1] = rotatedCamera.get1()/objectRatio;
+    mCamera[2] = rotatedCamera.get2()/objectRatio;
+
+    for( mLastTouchedAxis=0; mLastTouchedAxis<mNumFaceAxis; mLastTouchedAxis++)
+      {
+      if( faceIsVisible(mFaceAxis[mLastTouchedAxis]) )
+        {
+        castTouchPointOntoFace(mFaceAxis[mLastTouchedAxis], mTouch);
+        convertTo2Dcoords(mTouch, mFaceAxis[mLastTouchedAxis], mPoint2D);
+        if( isInsideFace(mPoint2D) ) return true;
+        }
+      }
+
+    return false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public Static2D newRotation(Static4D rotatedTouchPoint)
+    {
+    float objectRatio = RubikObject.getObjectRatio();
+
+    mPoint[0] = rotatedTouchPoint.get0()/objectRatio;
+    mPoint[1] = rotatedTouchPoint.get1()/objectRatio;
+    mPoint[2] = rotatedTouchPoint.get2()/objectRatio;
+
+    castTouchPointOntoFace(mFaceAxis[mLastTouchedAxis], mTouch);
+    convertTo2Dcoords(mTouch, mFaceAxis[mLastTouchedAxis], mMove2D);
+
+    mMove2D[0] -= mPoint2D[0];
+    mMove2D[1] -= mPoint2D[1];
+
+    int rotIndex = computeRotationIndex(mLastTouchedAxis, mMove2D);
+    float offset = computeOffset(mPoint2D, mCastAxis[mLastTouchedAxis][rotIndex]);
+
+    return new Static2D(rotIndex,offset);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getTouchedFace()
+    {
+    return mLastTouchedAxis;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[] getTouchedPoint3D()
+    {
+    return mTouch;
+    }
+  }
diff --git a/src/main/java/org/distorted/objects/RubikMovementCube.java b/src/main/java/org/distorted/objects/RubikMovementCube.java
index 775a1722..05d0cca8 100644
--- a/src/main/java/org/distorted/objects/RubikMovementCube.java
+++ b/src/main/java/org/distorted/objects/RubikMovementCube.java
@@ -21,7 +21,7 @@ package org.distorted.objects;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class RubikMovementCube extends RubikMovementObject
+class RubikMovementCube extends RubikMovement
 {
   RubikMovementCube()
     {
diff --git a/src/main/java/org/distorted/objects/RubikMovementDino.java b/src/main/java/org/distorted/objects/RubikMovementDino.java
index 8f05264a..0f57830f 100644
--- a/src/main/java/org/distorted/objects/RubikMovementDino.java
+++ b/src/main/java/org/distorted/objects/RubikMovementDino.java
@@ -21,7 +21,7 @@ package org.distorted.objects;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class RubikMovementDino extends RubikMovementObject
+class RubikMovementDino extends RubikMovement
 {
   RubikMovementDino()
     {
diff --git a/src/main/java/org/distorted/objects/RubikMovementObject.java b/src/main/java/org/distorted/objects/RubikMovementObject.java
deleted file mode 100644
index bcd43985..00000000
--- a/src/main/java/org/distorted/objects/RubikMovementObject.java
+++ /dev/null
@@ -1,316 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2020 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Magic Cube.                                                              //
-//                                                                                               //
-// Magic Cube is free software: you can redistribute it and/or modify                            //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Magic Cube 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 General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.objects;
-
-import org.distorted.library.type.Static2D;
-import org.distorted.library.type.Static3D;
-import org.distorted.library.type.Static4D;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-public abstract class RubikMovementObject
-  {
-  private int mLastTouchedAxis;
-  private float[] mPoint, mCamera, mTouch;
-  private float[] mPoint2D, mMove2D;
-  private float[][][] mCastAxis;
-  private int mLastTouchedLR;
-  private int mNumRotAxis, mNumFaceAxis, mNumFacesPerAxis;
-  private float mDistanceCenterFace3D, mDistanceCenterFace2D;
-  private Static3D[] mRotAxis, mFaceAxis;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  abstract boolean isInsideFace(float[] point);
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  RubikMovementObject(Static3D[] rotAxis, Static3D[] faceAxis, float distance3D, float distance2D)
-    {
-    mPoint = new float[3];
-    mCamera= new float[3];
-    mTouch = new float[3];
-
-    mPoint2D = new float[2];
-    mMove2D  = new float[2];
-
-    mRotAxis    = rotAxis;
-    mNumRotAxis = mRotAxis.length;
-    mFaceAxis   = faceAxis;
-    mNumFaceAxis= mFaceAxis.length;
-
-    mNumFacesPerAxis = mNumFaceAxis / mNumRotAxis;
-    mDistanceCenterFace3D = distance3D; // distance from the center of the object to each of its faces
-    mDistanceCenterFace2D = distance2D; // distance from the center of a face to its edge
-
-    // mCastAxis[1][2]{0,1} are the 2D coords of the 2nd axis cast onto the face defined by the
-    // 1st pair (axis,lr)
-    mCastAxis = new float[mNumFaceAxis][mNumRotAxis][2];
-
-    for( int casted=0; casted<mNumRotAxis; casted++)
-      {
-      Static3D a = mRotAxis[casted];
-      mPoint[0]= a.get0();
-      mPoint[1]= a.get1();
-      mPoint[2]= a.get2();
-
-      for( int surface=0; surface<mNumRotAxis; surface++)
-        for(int lr=0; lr<mNumFacesPerAxis; lr++)
-          {
-          int index = surface*mNumFacesPerAxis + lr;
-
-          if( casted!=surface )
-            {
-            convertTo2Dcoords( mPoint, mRotAxis[surface], lr, mPoint2D);
-            mCastAxis[index][casted][0] = mPoint2D[0];
-            mCastAxis[index][casted][1] = mPoint2D[1];
-            normalize2D(mCastAxis[index][casted]);
-            }
-          else
-            {
-            mCastAxis[index][casted][0] = 0;
-            mCastAxis[index][casted][1] = 0;
-            }
-          }
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void normalize2D(float[] vect)
-    {
-    float len = (float)Math.sqrt(vect[0]*vect[0] + vect[1]*vect[1]);
-    vect[0] /= len;
-    vect[1] /= len;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// find the casted axis with which our move2D vector forms an angle closest to 90 deg.
-
-  private int computeRotationIndex(int axis, int lr, float[] move2D)
-    {
-    float cosAngle, minCosAngle = Float.MAX_VALUE;
-    int minIndex=-1;
-    int index = axis*mNumFacesPerAxis + lr;
-    float m0 = move2D[0];
-    float m1 = move2D[1];
-    float len = (float)Math.sqrt(m0*m0 + m1*m1);
-
-    if( len!=0.0f )
-      {
-      m0 /= len;
-      m1 /= len;
-      }
-    else
-      {
-      m0 = 1.0f;  // arbitrarily
-      m1 = 0.0f;  //
-      }
-
-    for(int i=0; i<mNumRotAxis; i++)
-      {
-      if( axis != i )
-        {
-        cosAngle = m0*mCastAxis[index][i][0] +  m1*mCastAxis[index][i][1];
-        if( cosAngle<0 ) cosAngle = -cosAngle;
-
-        if( cosAngle<minCosAngle )
-          {
-          minCosAngle=cosAngle;
-          minIndex = i;
-          }
-        }
-      }
-
-    return minIndex;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private float computeOffset(float[] point, float[] axis)
-    {
-    return point[0]*axis[0] + point[1]*axis[1] + mDistanceCenterFace2D;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private boolean faceIsVisible(Static3D axis, int lr)
-    {
-    float castCameraOnAxis = mCamera[0]*axis.get0() + mCamera[1]*axis.get1() + mCamera[2]*axis.get2();
-    return (2*lr-1)*castCameraOnAxis > mDistanceCenterFace3D;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// given precomputed mCamera and mPoint, respectively camera and touch point positions in ScreenSpace,
-// compute point 'output[]' which:
-// 1) lies on a face of the Object, i.e. surface defined by (axis, distance from (0,0,0)) [and this
-//    distance is +-mDistanceCenterFace, depending if it is the face on the left or the right end of
-//    the axis] (lr=0 or 1, so (2lr-1)*mDistanceCenterFace)
-// 2) is co-linear with mCamera and mPoint
-//
-// output = camera + alpha*(point-camera), where alpha = [dist-axis*camera] / [axis*(point-camera)]
-
-  private void castTouchPointOntoFace(Static3D axis, int lr, float[] output)
-    {
-    float d0 = mPoint[0]-mCamera[0];
-    float d1 = mPoint[1]-mCamera[1];
-    float d2 = mPoint[2]-mCamera[2];
-    float a0 = axis.get0();
-    float a1 = axis.get1();
-    float a2 = axis.get2();
-
-    float denom = a0*d0 + a1*d1 + a2*d2;
-
-    if( denom != 0.0f )
-      {
-      float axisCam = a0*mCamera[0] + a1*mCamera[1] + a2*mCamera[2];
-      float distance = (2*lr-1)*mDistanceCenterFace3D;
-      float alpha = (distance-axisCam)/denom;
-
-      output[0] = mCamera[0] + d0*alpha;
-      output[1] = mCamera[1] + d1*alpha;
-      output[2] = mCamera[2] + d2*alpha;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Convert the 3D point3D into a 2D point on the same face surface, but in a different
-// coordinate system: a in-plane 2D coord where the origin is in the point where the axis intersects
-// the surface, and whose Y axis points 'north' i.e. is in the plane given by the 3D origin, the
-// original 3D Y axis and our 2D in-plane origin.
-// If those 3 points constitute a degenerate triangle which does not define a plane - which can only
-// happen if axis is vertical (or in theory when 2D origin and 3D origin meet, but that would have to
-// mean that the distance between the center of the Object and its faces is 0) - then we arbitrarily
-// decide that 2D Y = (0,0,-1) in the North Pole and (0,0,1) in the South Pole)
-
-  private void convertTo2Dcoords(float[] point3D, Static3D axis, int lr, float[] output)
-    {
-    float y0,y1,y2; // base Y vector of the 2D coord system
-    float a0 = axis.get0();
-    float a1 = axis.get1();
-    float a2 = axis.get2();
-
-    if( lr==0 )
-      {
-      a0=-a0; a1=-a1; a2=-a2;
-      }
-
-    if( a0==0.0f && a2==0.0f )
-      {
-      y0=0; y1=0; y2=-a1;
-      }
-    else if( a1==0.0f )
-      {
-      y0=0; y1=1; y2=0;
-      }
-    else
-      {
-      float norm = (float)(-a1/Math.sqrt(1-a1*a1));
-      y0 = norm*a0; y1= norm*(a1-1/a1); y2=norm*a2;
-      }
-
-    float x0 = y1*a2 - y2*a1;  //
-    float x1 = y2*a0 - y0*a2;  // (2D coord baseY) x (axis) = 2D coord baseX
-    float x2 = y0*a1 - y1*a0;  //
-
-    float originAlpha = point3D[0]*a0 + point3D[1]*a1 + point3D[2]*a2;
-
-    float origin0 = originAlpha*a0; // coords of the point where axis
-    float origin1 = originAlpha*a1; // intersects surface plane i.e.
-    float origin2 = originAlpha*a2; // the origin of our 2D coord system
-
-    float v0 = point3D[0] - origin0;
-    float v1 = point3D[1] - origin1;
-    float v2 = point3D[2] - origin2;
-
-    output[0] = v0*x0 + v1*x1 + v2*x2;
-    output[1] = v0*y0 + v1*y1 + v2*y2;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public boolean faceTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
-    {
-    float objectRatio = RubikObject.getObjectRatio();
-
-    mPoint[0]  = rotatedTouchPoint.get0()/objectRatio;
-    mPoint[1]  = rotatedTouchPoint.get1()/objectRatio;
-    mPoint[2]  = rotatedTouchPoint.get2()/objectRatio;
-
-    mCamera[0] = rotatedCamera.get0()/objectRatio;
-    mCamera[1] = rotatedCamera.get1()/objectRatio;
-    mCamera[2] = rotatedCamera.get2()/objectRatio;
-
-    for( mLastTouchedAxis=0; mLastTouchedAxis<mNumRotAxis; mLastTouchedAxis++)
-      {
-      for( mLastTouchedLR=0; mLastTouchedLR<mNumFacesPerAxis; mLastTouchedLR++)
-        {
-        if( faceIsVisible(mRotAxis[mLastTouchedAxis], mLastTouchedLR) )
-          {
-          castTouchPointOntoFace(mRotAxis[mLastTouchedAxis], mLastTouchedLR, mTouch);
-          convertTo2Dcoords(mTouch, mRotAxis[mLastTouchedAxis], mLastTouchedLR, mPoint2D);
-
-          if( isInsideFace(mPoint2D) ) return true;
-          }
-        }
-      }
-
-    return false;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public Static2D newRotation(Static4D rotatedTouchPoint)
-    {
-    float objectRatio = RubikObject.getObjectRatio();
-
-    mPoint[0] = rotatedTouchPoint.get0()/objectRatio;
-    mPoint[1] = rotatedTouchPoint.get1()/objectRatio;
-    mPoint[2] = rotatedTouchPoint.get2()/objectRatio;
-
-    castTouchPointOntoFace(mRotAxis[mLastTouchedAxis], mLastTouchedLR, mTouch);
-    convertTo2Dcoords(mTouch, mRotAxis[mLastTouchedAxis], mLastTouchedLR, mMove2D);
-
-    mMove2D[0] -= mPoint2D[0];
-    mMove2D[1] -= mPoint2D[1];
-
-    int rotIndex = computeRotationIndex(mLastTouchedAxis, mLastTouchedLR, mMove2D);
-    int index    = mLastTouchedAxis*mNumFacesPerAxis+mLastTouchedLR;
-    float offset = computeOffset(mPoint2D, mCastAxis[index][rotIndex]);
-
-    return new Static2D(rotIndex,offset);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public int getTouchedFace()
-    {
-    return mNumFacesPerAxis==2 ? 2*mLastTouchedAxis + 1 - mLastTouchedLR : mLastTouchedAxis;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public float[] getTouchedPoint3D()
-    {
-    return mTouch;
-    }
-  }
diff --git a/src/main/java/org/distorted/objects/RubikMovementPyraminx.java b/src/main/java/org/distorted/objects/RubikMovementPyraminx.java
index 2f7a0227..5ab1fed8 100644
--- a/src/main/java/org/distorted/objects/RubikMovementPyraminx.java
+++ b/src/main/java/org/distorted/objects/RubikMovementPyraminx.java
@@ -21,7 +21,7 @@ package org.distorted.objects;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class RubikMovementPyraminx extends RubikMovementObject
+class RubikMovementPyraminx extends RubikMovement
 {
   private static final float SQ6 = (float)Math.sqrt(6);
   private static final float SQ3 = (float)Math.sqrt(3);
diff --git a/src/main/java/org/distorted/objects/RubikObjectList.java b/src/main/java/org/distorted/objects/RubikObjectList.java
index 2c17be51..3a797e61 100644
--- a/src/main/java/org/distorted/objects/RubikObjectList.java
+++ b/src/main/java/org/distorted/objects/RubikObjectList.java
@@ -71,7 +71,7 @@ public enum RubikObjectList
 
   private final int[] mObjectSizes, mMaxLevels, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
   private final Class<? extends RubikObject> mObjectClass;
-  private final RubikMovementObject mObjectMovementClass;
+  private final RubikMovement mObjectMovementClass;
   private static final RubikObjectList[] objects;
   private static int mNumAll;
 
@@ -283,7 +283,7 @@ public enum RubikObjectList
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  RubikObjectList(int[][] info, Class<? extends RubikObject> object , RubikMovementObject movement)
+  RubikObjectList(int[][] info, Class<? extends RubikObject> object , RubikMovement movement)
     {
     int length = info.length;
 
@@ -373,7 +373,7 @@ public enum RubikObjectList
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public RubikMovementObject getObjectMovementClass()
+  public RubikMovement getObjectMovementClass()
     {
     return mObjectMovementClass;
     }
