Project

General

Profile

« Previous | Next » 

Revision 54588439

Added by Leszek Koltunski over 1 year ago

progress with Masterball - Cubits app works now.

View differences:

src/main/java/org/distorted/objectlib/touchcontrol/TouchControlBall.java
33 33
    mCamera= new float[3];
34 34
    }
35 35

  
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

  
38
  private void computeLongitudeAndLatitude(float A, float B, float C)
39
    {
40

  
41
    }
42

  
36 43
///////////////////////////////////////////////////////////////////////////////////////////////////
37 44

  
38 45
  public float returnRotationFactor(int[] numLayers, int row)
......
55 62
    }
56 63

  
57 64
///////////////////////////////////////////////////////////////////////////////////////////////////
58
// TODO
59 65

  
60 66
  public boolean objectTouched(Static4D rotatedTouchPoint, Static4D rotatedCamera)
61 67
    {
......
71 77
    float vy = mPoint[1]-mCamera[1];
72 78
    float vz = mPoint[2]-mCamera[2];
73 79

  
74
    float lenSq   = vx*vx + vy*vy + vz*vz;
75
    float vectorPr= vx*mCamera[0] + vy*mCamera[1] + vz*mCamera[2];
76
    float cLenSq  = (mCamera[0]*mCamera[0] + mCamera[1]*mCamera[1] + mCamera[2]*mCamera[2]);
80
    float A  = vx*vx + vy*vy + vz*vz;
81
    float Bsq= 4*(vx*mCamera[0] + vy*mCamera[1] + vz*mCamera[2]);
82
    float C  = (mCamera[0]*mCamera[0] + mCamera[1]*mCamera[1] + mCamera[2]*mCamera[2]) - mObjectRatio*mObjectRatio;
83

  
84
    float delta = Bsq - 4*A*C;
85

  
86
    if( delta>=0 )
87
      {
88
      float B = (float)Math.sqrt(Bsq);
89
      computeLongitudeAndLatitude(A,B,C);
90
      return true;
91
      }
77 92

  
78
    return vectorPr*vectorPr >= lenSq * (cLenSq - mObjectRatio*mObjectRatio);
93
    return false;
79 94
    }
80 95

  
81 96
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff