commit 092e257bd6372231d3434aab613b605c9cd5b7eb
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue May 9 17:17:23 2023 +0200

    Progress with support for the 'normal' touch-control: speed probes.

diff --git a/src/main/java/org/distorted/objectlib/main/ObjectControl.java b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
index 3f48a3e1..4a19cce2 100644
--- a/src/main/java/org/distorted/objectlib/main/ObjectControl.java
+++ b/src/main/java/org/distorted/objectlib/main/ObjectControl.java
@@ -58,9 +58,8 @@ public class ObjectControl
     private float mStartRotX, mStartRotY;
     private float mRotationFactor;
     private int mCurrentAxis, mCurrentRow;
-    private float mCurrentAngle, mCurrRotSpeed;
-    private final float[] mLastX;
-    private final float[] mLastY;
+    private float mCurrentAngle, mAvgRotSpeed;
+    private final float[] mLastA;
     private final long[] mLastT;
     private int mFirstIndex, mLastIndex;
     private final int mDensity;
@@ -80,7 +79,7 @@ public class ObjectControl
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private void addSpeedProbe(float x, float y)
+    private void addSpeedProbe(float angle)
       {
       long currTime = System.currentTimeMillis();
       boolean theSame = mLastIndex==mFirstIndex;
@@ -89,8 +88,7 @@ public class ObjectControl
       if( mLastIndex>=NUM_SPEED_PROBES ) mLastIndex=0;
 
       mLastT[mLastIndex] = currTime;
-      mLastX[mLastIndex] = x;
-      mLastY[mLastIndex] = y;
+      mLastA[mLastIndex] = angle;
 
       if( mLastIndex==mFirstIndex)
         {
@@ -101,8 +99,7 @@ public class ObjectControl
       if( theSame )
         {
         mLastT[mFirstIndex] = currTime;
-        mLastX[mFirstIndex] = x;
-        mLastY[mFirstIndex] = y;
+        mLastA[mFirstIndex] = angle;
         }
       }
 
@@ -110,19 +107,15 @@ public class ObjectControl
 
     private void computeCurrentSpeedInInchesPerSecond()
       {
-      long firstTime = mLastT[mFirstIndex];
-      long lastTime  = mLastT[mLastIndex];
-      float fX = mLastX[mFirstIndex];
-      float fY = mLastY[mFirstIndex];
-      float lX = mLastX[mLastIndex];
-      float lY = mLastY[mLastIndex];
-
-      long timeDiff = lastTime-firstTime;
+      long timeDiff = mLastT[mLastIndex]-mLastT[mFirstIndex];
+      float sum = 0;
+      for(int i=mFirstIndex; i<=mLastIndex; i++) sum += mLastA[i];
 
       mLastIndex = 0;
       mFirstIndex= 0;
 
-      mCurrRotSpeed = timeDiff>0 ? 1000*retFingerDragDistanceInInches(fX-lX,fY-lY)/timeDiff : 0;
+      mAvgRotSpeed = timeDiff>0 ? sum/timeDiff : 0;
+      if( mAvgRotSpeed<0 ) mAvgRotSpeed = -mAvgRotSpeed;
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -237,7 +230,7 @@ public class ObjectControl
         {
         computeCurrentSpeedInInchesPerSecond();
         int basic = angles[mCurrentAxis][mCurrentRow];
-        int angle = object.computeNearestAngle(basic,mCurrentAngle, mCurrRotSpeed);
+        int angle = object.computeNearestAngle(basic,mCurrentAngle, mAvgRotSpeed);
         mPreRender.finishRotation(angle);
         mPreRender.rememberMove(mCurrentAxis,mCurrentRow,angle);
 
@@ -273,14 +266,14 @@ public class ObjectControl
         float angle = (tmp>0 ? 1:-1)*len*mRotationFactor;
         mCurrentAngle = SWIPING_SENSITIVITY*angle;
         mPreRender.getObject().continueRotation(mCurrentAngle);
-
-        addSpeedProbe(x2,y2);
+        addSpeedProbe(mCurrentAngle);
         }
       else
         {
         float rotAngle = computeNormalRotAngle(mNormalTouchPoint[0]-x,mNormalTouchPoint[1]-y);
         mCurrentAngle = mNormalRotAngle - rotAngle;
         mPreRender.getObject().continueRotation(mCurrentAngle);
+        addSpeedProbe(mCurrentAngle);
         }
       }
 
@@ -353,7 +346,7 @@ public class ObjectControl
       if( object.beginNewRotation( mCurrentAxis, mCurrentRow ) )
         {
         mInterface.onBeginRotation();
-        addSpeedProbe(x,y);
+        addSpeedProbe(0);
         mBeginningRotation = false;
         mContinuingRotation= true;
         }
@@ -569,14 +562,13 @@ public class ObjectControl
       mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
       mTemp= new Static4D(0,0,0,1);
 
-      mCurrRotSpeed= 0.0f;
+      mAvgRotSpeed = 0.0f;
       mLastMode    = -1;
       mRotateOnCreation = false;
 
       mNormalTouchPoint = new float[2];
 
-      mLastX = new float[NUM_SPEED_PROBES];
-      mLastY = new float[NUM_SPEED_PROBES];
+      mLastA = new float[NUM_SPEED_PROBES];
       mLastT = new long[NUM_SPEED_PROBES];
       mFirstIndex= 0;
       mLastIndex = 0;
