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/TouchControl.java
9 9

  
10 10
package org.distorted.objectlib.touchcontrol;
11 11

  
12
import org.distorted.library.helpers.QuatHelper;
12 13
import org.distorted.library.type.Static4D;
13 14
import org.distorted.objectlib.main.TwistyObject;
14 15

  
......
204 205
      }
205 206
    }
206 207

  
208
///////////////////////////////////////////////////////////////////////////////////////////////////
209
// cast the 3D axis we are currently rotating along (which is already casted to the surface of the
210
// currently touched face AND converted into a 4D vector - fourth 0) to a 2D in-screen-surface axis
211

  
212
  void getCastedRotAxis(float[] output, Static4D quat, float x, float y, float z, float w)
213
    {
214
    Static4D result = QuatHelper.rotateVectorByQuat(x,y,z,w, quat);
215

  
216
    float cx = result.get0();
217
    float cy = result.get1();
218
    float len= (float)Math.sqrt(cx*cx+cy*cy);
219

  
220
    if( len!=0 )
221
      {
222
      output[0] = cx/len;
223
      output[1] = cy/len;
224
      }
225
    else
226
      {
227
      output[0] = 1;
228
      output[1] = 0;
229
      }
230
    }
231

  
207 232
///////////////////////////////////////////////////////////////////////////////////////////////////
208 233

  
209 234
  public abstract boolean objectTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera);

Also available in: Unified diff