Project

General

Profile

« Previous | Next » 

Revision ef018c1b

Added by Leszek Koltunski over 2 years ago

Abstract the next function, computeRowFromOffset(), out of the individual Movement classes.
Still two issues:

1) mysterious 1.5 multiplier in Movement12
2) in Movement8, moving the offset works only if the rotAxis are face-turning, i.e. they connect the centers of the opposing faces of the octahedron.

View differences:

src/main/java/org/distorted/objects/Movement6.java
19 19

  
20 20
package org.distorted.objects;
21 21

  
22
import static org.distorted.objects.TwistyObject.SQ2;
23

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

  
24 26
///////////////////////////////////////////////////////////////////////////////////////////////////
......
36 38
           new Static3D(0,0,1), new Static3D(0,0,-1)
37 39
         };
38 40

  
41
  private final float[][] mTouchBorders;
42

  
39 43
///////////////////////////////////////////////////////////////////////////////////////////////////
40 44

  
41
  Movement6(Static3D[] rotAxis)
45
  Movement6(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers)
42 46
    {
43 47
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
48
    float scale = 1.0f/numLayers; // 1.0 is (2*DIST3D)/(2*DIST2D)
49
    mTouchBorders = computeBorders(scale,cuts,rotatable);
50
    }
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
54
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
55
    {
56
    float[] borders = mTouchBorders[axisIndex];
57
    int len = borders.length;
58

  
59
    for(int i=0; i<len; i++)
60
      {
61
      if( offset<borders[i] ) return i;
62
      }
63

  
64
    return len;
44 65
    }
45 66

  
46 67
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff