Project

General

Profile

« Previous | Next » 

Revision 48154f68

Added by Leszek Koltunski over 3 years ago

New 'JingPyraminx' object - improvements. The object should be working now.

View differences:

src/main/java/org/distorted/objects/MovementJing.java
21 21

  
22 22
import org.distorted.library.type.Static3D;
23 23

  
24
import static org.distorted.objects.TwistyJing.F;
25

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
25 27

  
26 28
class MovementJing extends Movement
27 29
{
28
  private static final float M = (1.0f/4);
29
  static final float DIST3D = (SQ6/12)*M;
30
  static final float DIST2D = (SQ3/ 6)*M;
30
  static final float DIST3D = SQ6/24;
31
  static final float DIST2D = SQ3/12;
31 32

  
32 33
  static final Static3D[] FACE_AXIS = new Static3D[]
33 34
         {
......
48 49

  
49 50
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
50 51
    {
51
    return (int)(numLayers*offset/(SQ6/3));
52
    return offset < (SQ3/4)*F ? 0:1;
52 53
    }
53 54

  
54 55
///////////////////////////////////////////////////////////////////////////////////////////////////
55 56

  
56 57
  public float returnRotationFactor(int numLayers, int row)
57 58
    {
58
    return ((float)numLayers)/(numLayers-row);
59
    return 1.0f;
59 60
    }
60 61

  
61 62
///////////////////////////////////////////////////////////////////////////////////////////////////
......
64 65
    {
65 66
    float y = (face > 1 ? p[1] : -p[1]);
66 67
    float x = p[0];
67

  
68
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
68
    return (y >= -DIST2D) && (y <= 2*DIST2D-SQ3*x) && (y <= 2*DIST2D+SQ3*x);
69 69
    }
70 70

  
71 71
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/MovementPyraminx.java
63 63
    {
64 64
    float y = (face > 1 ? p[1] : -p[1]);
65 65
    float x = p[0];
66

  
67
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
66
    return (y >= -DIST2D) && (y <= 2*DIST2D-SQ3*x) && (y <= 2*DIST2D+SQ3*x);
68 67
    }
69 68

  
70 69
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyJing.java
242 242

  
243 243
  float[][] getCuts(int size)
244 244
    {
245
    float[] cut = {F-0.5f};
245
    float[] cut = { (F-0.25f)*(SQ6/3) };
246 246
    return new float[][] { cut,cut,cut,cut };
247 247
    }
248 248

  

Also available in: Unified diff