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/Movement4.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
///////////////////////////////////////////////////////////////////////////////////////////////////
......
37 39
           new Static3D(+SQ6/3,-SQ3/3,     0),
38 40
         };
39 41

  
42
  private final float[][] mTouchBorders;
43

  
40 44
///////////////////////////////////////////////////////////////////////////////////////////////////
41 45

  
42
  Movement4(Static3D[] rotAxis)
46
  Movement4(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable,int numLayers)
43 47
    {
44 48
    super(rotAxis, FACE_AXIS, DIST3D, DIST2D);
49
    float scale = (3*SQ2/4)/numLayers; // 3*SQ2/4 is height(face)/height(tetra)
50
    mTouchBorders = computeBorders(scale,cuts,rotatable);
51
    }
52

  
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

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

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

  
65
    return len;
45 66
    }
46 67

  
47 68
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff