Project

General

Profile

« Previous | Next » 

Revision 52375039

Added by Leszek Koltunski about 2 months ago

improvement

View differences:

src/main/java/org/distorted/objectlib/touchcontrol/TouchControlShapeChanging.java
97 97
  // end FaceInfo
98 98

  
99 99
  private final float[] mTouch, mLastT;
100
  private final Static4D mTmpAxis;
101 100
  private int mNumCubits;
102 101
  private int[] mNumFaces;
103 102
  private boolean mPreparationDone;
......
123 122
    mLastT = new float[3];
124 123
    mObject= object;
125 124
    mPreparationDone = false;
126
    mTmpAxis = new Static4D(0,0,0,0);
127 125
    mGhostAxisEnabled = -1;
128 126

  
129 127
    if( object!=null )
......
717 715

  
718 716
  public void getCastedRotAxis(float[] output, Static4D quat, int axisIndex)
719 717
    {
720
    Static3D rotAxis = mRotAxis[axisIndex];
721
    float rx = rotAxis.get0();
722
    float ry = rotAxis.get1();
723
    float rz = rotAxis.get2();
724

  
725
    mTmpAxis.set(rx,ry,rz,0);
726
    Static4D result = QuatHelper.rotateVectorByQuat(mTmpAxis, quat);
727

  
728
    float cx =result.get0();
729
    float cy =result.get1();
730

  
731
    float len = (float)Math.sqrt(cx*cx+cy*cy);
732

  
733
    if( len!=0 )
734
      {
735
      output[0] = cx/len;
736
      output[1] = cy/len;
737
      }
738
    else
739
      {
740
      output[0] = 1;
741
      output[1] = 0;
742
      }
718
    Static3D a = mRotAxis[axisIndex];
719
    getCastedRotAxis(output,quat,a.get0(),a.get1(),a.get2(),0);
743 720
    }
744 721

  
745 722
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff