commit c02559512bb8c053dc4511613065e2b390815177
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu May 11 15:28:18 2023 +0200

    Completely kick out the android.opengl.Matrix dependency from the library.

diff --git a/src/main/java/org/distorted/library/effect/MatrixEffectRotate.java b/src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
index 53b0d87..9405340 100644
--- a/src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
+++ b/src/main/java/org/distorted/library/effect/MatrixEffectRotate.java
@@ -32,6 +32,8 @@ public class MatrixEffectRotate extends MatrixEffect
   {
   private final Data1D mAngle;
   private final Data3D mAxis, mCenter;
+  private float[] mTmp1 = new float[16];
+  private float[] mTmp2 = new float[16];
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
@@ -63,12 +65,16 @@ public class MatrixEffectRotate extends MatrixEffect
     float y = uniforms[NUM_FLOAT_UNIFORMS*index+CENTER_OFFSET+1];
     float z = uniforms[NUM_FLOAT_UNIFORMS*index+CENTER_OFFSET+2];
 
+    double inRadians = Math.PI*angle/180;
+    float sin = (float)Math.sin(inRadians);
+    float cos = (float)Math.cos(inRadians);
+
     MatrixHelper.translate(matrixP, x, y, z);
-    MatrixHelper.rotate(matrixP, angle, axisX, axisY, axisZ);
+    MatrixHelper.rotateSinCos(matrixP, mTmp1, mTmp2, sin,cos, axisX, axisY, axisZ);
     MatrixHelper.translate(matrixP,-x,-y,-z);
 
     MatrixHelper.translate(matrixV, x, y, z);
-    MatrixHelper.rotate(matrixV, angle, axisX, axisY, axisZ);
+    MatrixHelper.rotateSinCos(matrixV, mTmp1, mTmp2, sin,cos, axisX, axisY, axisZ);
     MatrixHelper.translate(matrixV,-x,-y,-z);
     }
 
diff --git a/src/main/java/org/distorted/library/helpers/MatrixHelper.java b/src/main/java/org/distorted/library/helpers/MatrixHelper.java
index 723dec5..3c366ba 100644
--- a/src/main/java/org/distorted/library/helpers/MatrixHelper.java
+++ b/src/main/java/org/distorted/library/helpers/MatrixHelper.java
@@ -123,10 +123,46 @@ public class MatrixHelper
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// this is android.opengl.Matrix.rotateM(), but with pre-computed sin and cos of the angle
+// and also we have to pre-allocate and pass here two temp arrays.
 
-  public static void rotate(float[] output, float angle, float axisX, float axisY, float axisZ)
+  public static void rotateSinCos(float[] output, float[] tmp1, float[] tmp2, float sin, float cos, float x, float y, float z)
     {
-    android.opengl.Matrix.rotateM(output,0,angle,axisX,axisY,axisZ);
+    tmp1[0]  = (1-cos)*x*x + cos;
+    tmp1[1]  = (1-cos)*x*y + sin*z;
+    tmp1[2]  = (1-cos)*x*z - sin*y;
+    tmp1[3]  = 0;
+    tmp1[4]  = (1-cos)*x*y - sin*z;
+    tmp1[5]  = (1-cos)*y*y + cos;
+    tmp1[6]  = (1-cos)*y*z + sin*x;
+    tmp1[7]  = 0;
+    tmp1[8]  = (1-cos)*x*z + sin*y;
+    tmp1[9]  = (1-cos)*y*z - sin*x;
+    tmp1[10] = (1-cos)*z*z + cos;
+    tmp1[11] = 0;
+    tmp1[12] = 0;
+    tmp1[13] = 0;
+    tmp1[14] = 0;
+    tmp1[15] = 1;
+
+    tmp2[0]  =  output[ 0];
+    tmp2[1]  =  output[ 1];
+    tmp2[2]  =  output[ 2];
+    tmp2[3]  =  output[ 3];
+    tmp2[4]  =  output[ 4];
+    tmp2[5]  =  output[ 5];
+    tmp2[6]  =  output[ 6];
+    tmp2[7]  =  output[ 7];
+    tmp2[8]  =  output[ 8];
+    tmp2[9]  =  output[ 9];
+    tmp2[10] =  output[10];
+    tmp2[11] =  output[11];
+    tmp2[12] =  output[12];
+    tmp2[13] =  output[13];
+    tmp2[14] =  output[14];
+    tmp2[15] =  output[15];
+
+    multiply(output,tmp2,tmp1);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
