Project

General

Profile

« Previous | Next » 

Revision be7c9190

Added by Leszek Koltunski over 2 years ago

Abstract out some methods from the Movement classes. only two remain now: rowFromOffset and enabledAxis.

View differences:

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

  
20 20
package org.distorted.objects;
21 21

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

  
24 22
///////////////////////////////////////////////////////////////////////////////////////////////////
25 23

  
26
class MovementPyraminx extends Movement
24
class MovementPyraminx extends Movement4
27 25
{
28
  static final float DIST3D = SQ6/12;
29
  static final float DIST2D = SQ3/6;
30

  
31
  static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(     0,+SQ3/3,+SQ6/3),
34
           new Static3D(     0,+SQ3/3,-SQ6/3),
35
           new Static3D(-SQ6/3,-SQ3/3,     0),
36
           new Static3D(+SQ6/3,-SQ3/3,     0),
37
         };
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41 26
  MovementPyraminx()
42 27
    {
43
    super(TwistyPyraminx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
28
    super(TwistyPyraminx.ROT_AXIS);
44 29
    }
45 30

  
46 31
///////////////////////////////////////////////////////////////////////////////////////////////////
......
50 35
    return (int)(numLayers*offset/(SQ6/3));
51 36
    }
52 37

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

  
55
  public float returnRotationFactor(int numLayers, int row)
56
    {
57
    return ((float)numLayers)/(numLayers-row);
58
    }
59

  
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

  
62
  boolean isInsideFace(int face, float[] p)
63
    {
64
    float y = (face > 1 ? p[1] : -p[1]);
65
    float x = p[0];
66
    return (y >= -DIST2D) && (y <= 2*DIST2D-SQ3*x) && (y <= 2*DIST2D+SQ3*x);
67
    }
68

  
69 38
///////////////////////////////////////////////////////////////////////////////////////////////////
70 39

  
71 40
  void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)

Also available in: Unified diff