Project

General

Profile

« Previous | Next » 

Revision f86b282a

Added by Leszek Koltunski over 2 years ago

Minor.

View differences:

src/main/java/org/distorted/objectlib/main/Movement12.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import static org.distorted.objectlib.main.TwistyObject.SQ5;
23

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

  
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
// Dodecahedral objects: map the 2D swipes of user's fingers to 3D rotations
28

  
29
public class Movement12 extends Movement
30
{
31
  public static final float C2       = (SQ5+3)/4;
32
  public static final float LEN      = (float)(Math.sqrt(1.25f+0.5f*SQ5));
33
  public static final float SIN54    = (SQ5+1)/4;
34
  public static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
35

  
36
  public  static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5);
37
  private static final float DIST2D = (SIN54/COS54)/2;
38
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,
39
                                        DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
40

  
41
  public static final Static3D[] FACE_AXIS = new Static3D[]
42
         {
43
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
44
           new Static3D(    C2/LEN,-SIN54/LEN,    0      ),
45
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
46
           new Static3D(   -C2/LEN,-SIN54/LEN,    0      ),
47
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
48
           new Static3D( 0        ,    C2/LEN,-SIN54/LEN ),
49
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
50
           new Static3D( 0        ,   -C2/LEN,-SIN54/LEN ),
51
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
52
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN ),
53
           new Static3D(-SIN54/LEN,    0     ,    C2/LEN ),
54
           new Static3D(-SIN54/LEN,    0     ,   -C2/LEN )
55
         };
56

  
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

  
59
  public Movement12(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
60
    {
61
    super(rotAxis, FACE_AXIS, cuts,rotatable,D3D, size, type, enabled);
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  public float returnRotationFactor(int[] numLayers, int row)
67
    {
68
    return 1.0f;
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
// return angle (in radians) that the line connecting the center C of the pentagonal face and the
73
// first vertex of the pentagon makes with a vertical line coming upwards from the center C.
74

  
75
  private float returnAngle(int face)
76
    {
77
    switch(face)
78
      {
79
      case  0:
80
      case  2:
81
      case  6:
82
      case  7: return 0.0f;
83
      case  1:
84
      case  3:
85
      case  4:
86
      case  5: return (float)(36*Math.PI/180);
87
      case  9:
88
      case 10: return (float)(54*Math.PI/180);
89
      case  8:
90
      case 11: return (float)(18*Math.PI/180);
91
      }
92

  
93
    return 0.0f;
94
    }
95

  
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector
98
// from the center of the coordinate system to P.
99
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at
100
// P' and going in the direction of V.
101
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of
102
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points
103
// directly upwards, is 'point' on the left or the right of it?
104

  
105
  private boolean isOnTheLeft(float[] point, float distance, float angle)
106
    {
107
    float sin = (float)Math.sin(angle);
108
    float cos = (float)Math.cos(angle);
109

  
110
    float vx = point[0] + sin*distance;
111
    float vy = point[1] - cos*distance;
112

  
113
    return vx*sin < vy*cos;
114
    }
115

  
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

  
118
  int returnPart(int type, int face, float[] point)
119
    {
120
    switch(type)
121
      {
122
      case TYPE_SPLIT_EDGE  : return partEdge(point,face);
123
      case TYPE_SPLIT_CORNER: return partCorner(point,face);
124
      default               : return 0;
125
      }
126
    }
127

  
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
// Return 0,1,2,3,4 - the vertex of the pentagon to which point 'point' is the closest, if the
130
// 'point' is inside the pentagon - or -1 otherwise.
131
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00.
132
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the
133
// pentagon.
134
// Distance from the center to a vertex of the pentagon = 1/(6*COS54)
135

  
136
  int partEdge(float[] point, int face)
137
    {
138
    float angle = returnAngle(face);
139
    float A = (float)(Math.PI/5);
140

  
141
    for(int i=0; i<5; i++)
142
      {
143
      if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return -1;
144
      }
145

  
146
    if( isOnTheLeft(point, 0, 2.5f*A-angle) )
147
      {
148
      if( isOnTheLeft(point, 0, 3.5f*A-angle) )
149
        {
150
        return isOnTheLeft(point, 0, 5.5f*A-angle) ? 3 : 4;
151
        }
152
      else return 0;
153
      }
154
    else
155
      {
156
      if( isOnTheLeft(point, 0, 4.5f*A-angle) )
157
        {
158
        return 2;
159
        }
160
      else
161
        {
162
        return isOnTheLeft(point, 0, 6.5f*A-angle) ? 1 : 0;
163
        }
164
      }
165
    }
166

  
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168
// TODO - no such object yet
169

  
170
  int partCorner(float[] point, int face)
171
    {
172
    return 0;
173
    }
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  boolean isInsideFace(int face, float[] p)
178
    {
179
    float angle = returnAngle(face);
180
    float A = (float)(Math.PI/5);
181

  
182
    for(int i=0; i<5; i++)
183
      {
184
      if( isOnTheLeft(p, DIST2D, (9-2*i)*A-angle) ) return false;
185
      }
186

  
187
    return true;
188
    }
189
}
src/main/java/org/distorted/objectlib/main/Movement4.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Tetrahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class Movement4 extends Movement
28
{
29
  private static final float DIST3D = SQ6/12;
30
  private static final float DIST2D = SQ3/6;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(     0,+SQ3/3,+SQ6/3),
37
           new Static3D(     0,+SQ3/3,-SQ6/3),
38
           new Static3D(-SQ6/3,-SQ3/3,     0),
39
           new Static3D(+SQ6/3,-SQ3/3,     0),
40
         };
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public Movement4(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
45
    {
46
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
// corner    edge
51
//   |       \ 0 /
52
// 2 | 0      \ /
53
//  / \      2 | 1
54
// / 1 \       |
55

  
56
  int returnPart(int type, int face, float[] touchPoint)
57
    {
58
    switch(type)
59
      {
60
      case TYPE_NOT_SPLIT   : return 0;
61

  
62
      case TYPE_SPLIT_EDGE  : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
63
                              float x1 = touchPoint[0];
64

  
65
                              boolean e0 = x1>0;
66
                              boolean e1 = y1>(+SQ3/3)*x1;
67
                              boolean e2 = y1>(-SQ3/3)*x1;
68

  
69
                              if(  e1 && e2 ) return 0;
70
                              if( !e1 && e0 ) return 1;
71
                              if( !e0 &&!e2 ) return 2;
72

  
73
      case TYPE_SPLIT_CORNER: float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
74
                              float x2 = touchPoint[0];
75

  
76
                              boolean c0 = x2>0;
77
                              boolean c1 = y2>(+SQ3/3)*x2;
78
                              boolean c2 = y2>(-SQ3/3)*x2;
79

  
80
                              if(  c0 && c2 ) return 0;
81
                              if( !c1 &&!c2 ) return 1;
82
                              if( !c0 && c1 ) return 2;
83
      }
84

  
85
    return 0;
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
// Jing has nL=2
90

  
91
  public float returnRotationFactor(int[] numLayers, int row)
92
    {
93
    int numL = numLayers[0];
94

  
95
    return numL==2 ? 1.0f : ((float)numL)/(numL-row);
96
    }
97

  
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

  
100
  boolean isInsideFace(int face, float[] p)
101
    {
102
    float y = (face > 1 ? p[1] : -p[1]);
103
    float x = p[0];
104
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
105
    }
106
}
src/main/java/org/distorted/objectlib/main/Movement6.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Hexahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class Movement6 extends Movement
28
{
29
  private static final float DIST3D = 0.5f;
30
  private static final float DIST2D = 0.5f;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(1,0,0), new Static3D(-1,0,0),
37
           new Static3D(0,1,0), new Static3D(0,-1,0),
38
           new Static3D(0,0,1), new Static3D(0,0,-1)
39
         };
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public Movement6(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
44
    {
45
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
//  corner    edge
50
//  \ 0 /     3 | 0
51
// 3 \ / 1  ___ | ___
52
//   / \        |
53
//  / 2 \     2 | 1
54

  
55
  int returnPart(int type, int face, float[] touchPoint)
56
    {
57
    switch(type)
58
      {
59
      case TYPE_NOT_SPLIT   : return 0;
60
      case TYPE_SPLIT_EDGE  : boolean e0 = touchPoint[0] > 0;
61
                              boolean e1 = touchPoint[1] > 0;
62
                              return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
63
      case TYPE_SPLIT_CORNER: boolean c0 = touchPoint[1] >= touchPoint[0];
64
                              boolean c1 = touchPoint[1] >=-touchPoint[0];
65
                              return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
66
      }
67

  
68
    return 0;
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

  
73
  public float returnRotationFactor(int[] numLayers, int row)
74
    {
75
    return 1.0f;
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  boolean isInsideFace(int face, float[] p)
81
    {
82
    return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
83
    }
84
}
src/main/java/org/distorted/objectlib/main/Movement8.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Octahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class Movement8 extends Movement
28
{
29
  private static final float DIST3D = SQ6/6;
30
  private static final float DIST2D = SQ3/6;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(+SQ6/3,+SQ3/3,     0), new Static3D(-SQ6/3,-SQ3/3,     0),
37
           new Static3D(-SQ6/3,+SQ3/3,     0), new Static3D(+SQ6/3,-SQ3/3,     0),
38
           new Static3D(     0,+SQ3/3,+SQ6/3), new Static3D(     0,-SQ3/3,-SQ6/3),
39
           new Static3D(     0,+SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3,+SQ6/3)
40
         };
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public Movement8(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
45
    {
46
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
// corner    edge
51
//   |       \ 0 /
52
// 2 | 0      \ /
53
//  / \      2 | 1
54
// / 1 \       |
55

  
56
  int returnPart(int type, int face, float[] touchPoint)
57
    {
58
    switch(type)
59
      {
60
      case TYPE_NOT_SPLIT   : return 0;
61

  
62
      case TYPE_SPLIT_EDGE  : float y1 = (face%2 == 0 ? touchPoint[1] : -touchPoint[1]);
63
                              float x1 = touchPoint[0];
64

  
65
                              boolean e0 = x1>0;
66
                              boolean e1 = y1>(+SQ3/3)*x1;
67
                              boolean e2 = y1>(-SQ3/3)*x1;
68

  
69
                              if(  e1 && e2 ) return 0;
70
                              if( !e1 && e0 ) return 1;
71
                              if( !e0 &&!e2 ) return 2;
72

  
73
      case TYPE_SPLIT_CORNER: float y2 = (face%2 == 0 ? touchPoint[1] : -touchPoint[1]);
74
                              float x2 = touchPoint[0];
75

  
76
                              boolean c0 = x2>0;
77
                              boolean c1 = y2>(+SQ3/3)*x2;
78
                              boolean c2 = y2>(-SQ3/3)*x2;
79

  
80
                              if(  c0 && c2 ) return 0;
81
                              if( !c1 &&!c2 ) return 1;
82
                              if( !c0 && c1 ) return 2;
83
      }
84

  
85
    return 0;
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  public float returnRotationFactor(int[] numLayers, int row)
91
    {
92
    return 1.0f;
93
    }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

  
97
  boolean isInsideFace(int face, float[] p)
98
    {
99
    float y = (face%2 == 0 ? p[1] : -p[1]);
100
    float x = p[0];
101
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
102
    }
103
}
src/main/java/org/distorted/objectlib/main/MovementC.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Cuboids
26

  
27
public class MovementC extends Movement
28
{
29
  private final float[] mDist3D;
30

  
31
  public static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(1,0,0), new Static3D(-1,0,0),
34
           new Static3D(0,1,0), new Static3D(0,-1,0),
35
           new Static3D(0,0,1), new Static3D(0,0,-1)
36
         };
37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
  public MovementC(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type,
41
                   int[][][] enabled, float[] dist3D)
42
    {
43
    super(rotAxis, FACE_AXIS, cuts, rotatable, dist3D, size, type, enabled);
44

  
45
    mDist3D = dist3D;
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  int returnPart(int type, int face, float[] touchPoint)
51
    {
52
    return 0;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

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

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  boolean isInsideFace(int face, float[] p)
65
    {
66
    switch(face/2)
67
      {
68
      case 0: return ( p[0]<=mDist3D[4] && p[0]>=-mDist3D[4] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
69
      case 1: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[4] && p[1]>=-mDist3D[4] );
70
      case 2: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
71
      }
72
    return false;
73
    }
74
}
src/main/java/org/distorted/objectlib/main/MovementCuboids.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Cuboids
26

  
27
public class MovementCuboids extends Movement
28
{
29
  private final float[] mDist3D;
30

  
31
  public static final Static3D[] FACE_AXIS = new Static3D[]
32
         {
33
           new Static3D(1,0,0), new Static3D(-1,0,0),
34
           new Static3D(0,1,0), new Static3D(0,-1,0),
35
           new Static3D(0,0,1), new Static3D(0,0,-1)
36
         };
37

  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

  
40
  public MovementCuboids(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type,
41
                         int[][][] enabled, float[] dist3D)
42
    {
43
    super(rotAxis, FACE_AXIS, cuts, rotatable, dist3D, size, type, enabled);
44

  
45
    mDist3D = dist3D;
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  int returnPart(int type, int face, float[] touchPoint)
51
    {
52
    return 0;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

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

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  boolean isInsideFace(int face, float[] p)
65
    {
66
    switch(face/2)
67
      {
68
      case 0: return ( p[0]<=mDist3D[4] && p[0]>=-mDist3D[4] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
69
      case 1: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[4] && p[1]>=-mDist3D[4] );
70
      case 2: return ( p[0]<=mDist3D[0] && p[0]>=-mDist3D[0] && p[1]<=mDist3D[2] && p[1]>=-mDist3D[2] );
71
      }
72
    return false;
73
    }
74
}
src/main/java/org/distorted/objectlib/main/MovementDodecahedron.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import static org.distorted.objectlib.main.TwistyObject.SQ5;
23

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

  
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
// Dodecahedral objects: map the 2D swipes of user's fingers to 3D rotations
28

  
29
public class MovementDodecahedron extends Movement
30
{
31
  public static final float C2       = (SQ5+3)/4;
32
  public static final float LEN      = (float)(Math.sqrt(1.25f+0.5f*SQ5));
33
  public static final float SIN54    = (SQ5+1)/4;
34
  public static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
35

  
36
  public  static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5);
37
  private static final float DIST2D = (SIN54/COS54)/2;
38
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,
39
                                        DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
40

  
41
  public static final Static3D[] FACE_AXIS = new Static3D[]
42
         {
43
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
44
           new Static3D(    C2/LEN,-SIN54/LEN,    0      ),
45
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
46
           new Static3D(   -C2/LEN,-SIN54/LEN,    0      ),
47
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
48
           new Static3D( 0        ,    C2/LEN,-SIN54/LEN ),
49
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
50
           new Static3D( 0        ,   -C2/LEN,-SIN54/LEN ),
51
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
52
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN ),
53
           new Static3D(-SIN54/LEN,    0     ,    C2/LEN ),
54
           new Static3D(-SIN54/LEN,    0     ,   -C2/LEN )
55
         };
56

  
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

  
59
  public MovementDodecahedron(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
60
    {
61
    super(rotAxis, FACE_AXIS, cuts,rotatable,D3D, size, type, enabled);
62
    }
63

  
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

  
66
  public float returnRotationFactor(int[] numLayers, int row)
67
    {
68
    return 1.0f;
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
// return angle (in radians) that the line connecting the center C of the pentagonal face and the
73
// first vertex of the pentagon makes with a vertical line coming upwards from the center C.
74

  
75
  private float returnAngle(int face)
76
    {
77
    switch(face)
78
      {
79
      case  0:
80
      case  2:
81
      case  6:
82
      case  7: return 0.0f;
83
      case  1:
84
      case  3:
85
      case  4:
86
      case  5: return (float)(36*Math.PI/180);
87
      case  9:
88
      case 10: return (float)(54*Math.PI/180);
89
      case  8:
90
      case 11: return (float)(18*Math.PI/180);
91
      }
92

  
93
    return 0.0f;
94
    }
95

  
96
///////////////////////////////////////////////////////////////////////////////////////////////////
97
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector
98
// from the center of the coordinate system to P.
99
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at
100
// P' and going in the direction of V.
101
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of
102
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points
103
// directly upwards, is 'point' on the left or the right of it?
104

  
105
  private boolean isOnTheLeft(float[] point, float distance, float angle)
106
    {
107
    float sin = (float)Math.sin(angle);
108
    float cos = (float)Math.cos(angle);
109

  
110
    float vx = point[0] + sin*distance;
111
    float vy = point[1] - cos*distance;
112

  
113
    return vx*sin < vy*cos;
114
    }
115

  
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

  
118
  int returnPart(int type, int face, float[] point)
119
    {
120
    switch(type)
121
      {
122
      case TYPE_SPLIT_EDGE  : return partEdge(point,face);
123
      case TYPE_SPLIT_CORNER: return partCorner(point,face);
124
      default               : return 0;
125
      }
126
    }
127

  
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
// Return 0,1,2,3,4 - the vertex of the pentagon to which point 'point' is the closest, if the
130
// 'point' is inside the pentagon - or -1 otherwise.
131
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00.
132
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the
133
// pentagon.
134
// Distance from the center to a vertex of the pentagon = 1/(6*COS54)
135

  
136
  int partEdge(float[] point, int face)
137
    {
138
    float angle = returnAngle(face);
139
    float A = (float)(Math.PI/5);
140

  
141
    for(int i=0; i<5; i++)
142
      {
143
      if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return -1;
144
      }
145

  
146
    if( isOnTheLeft(point, 0, 2.5f*A-angle) )
147
      {
148
      if( isOnTheLeft(point, 0, 3.5f*A-angle) )
149
        {
150
        return isOnTheLeft(point, 0, 5.5f*A-angle) ? 3 : 4;
151
        }
152
      else return 0;
153
      }
154
    else
155
      {
156
      if( isOnTheLeft(point, 0, 4.5f*A-angle) )
157
        {
158
        return 2;
159
        }
160
      else
161
        {
162
        return isOnTheLeft(point, 0, 6.5f*A-angle) ? 1 : 0;
163
        }
164
      }
165
    }
166

  
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168
// TODO - no such object yet
169

  
170
  int partCorner(float[] point, int face)
171
    {
172
    return 0;
173
    }
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  boolean isInsideFace(int face, float[] p)
178
    {
179
    float angle = returnAngle(face);
180
    float A = (float)(Math.PI/5);
181

  
182
    for(int i=0; i<5; i++)
183
      {
184
      if( isOnTheLeft(p, DIST2D, (9-2*i)*A-angle) ) return false;
185
      }
186

  
187
    return true;
188
    }
189
}
src/main/java/org/distorted/objectlib/main/MovementHexahedron.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Hexahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class MovementHexahedron extends Movement
28
{
29
  private static final float DIST3D = 0.5f;
30
  private static final float DIST2D = 0.5f;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(1,0,0), new Static3D(-1,0,0),
37
           new Static3D(0,1,0), new Static3D(0,-1,0),
38
           new Static3D(0,0,1), new Static3D(0,0,-1)
39
         };
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public MovementHexahedron(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
44
    {
45
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49
//  corner    edge
50
//  \ 0 /     3 | 0
51
// 3 \ / 1  ___ | ___
52
//   / \        |
53
//  / 2 \     2 | 1
54

  
55
  int returnPart(int type, int face, float[] touchPoint)
56
    {
57
    switch(type)
58
      {
59
      case TYPE_NOT_SPLIT   : return 0;
60
      case TYPE_SPLIT_EDGE  : boolean e0 = touchPoint[0] > 0;
61
                              boolean e1 = touchPoint[1] > 0;
62
                              return e0 ? (e1 ? 0:1) : (e1 ? 3:2);
63
      case TYPE_SPLIT_CORNER: boolean c0 = touchPoint[1] >= touchPoint[0];
64
                              boolean c1 = touchPoint[1] >=-touchPoint[0];
65
                              return c0 ? (c1 ? 0:3) : (c1 ? 1:2);
66
      }
67

  
68
    return 0;
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

  
73
  public float returnRotationFactor(int[] numLayers, int row)
74
    {
75
    return 1.0f;
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  boolean isInsideFace(int face, float[] p)
81
    {
82
    return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
83
    }
84
}
src/main/java/org/distorted/objectlib/main/MovementOctahedron.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Octahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class MovementOctahedron extends Movement
28
{
29
  private static final float DIST3D = SQ6/6;
30
  private static final float DIST2D = SQ3/6;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(+SQ6/3,+SQ3/3,     0), new Static3D(-SQ6/3,-SQ3/3,     0),
37
           new Static3D(-SQ6/3,+SQ3/3,     0), new Static3D(+SQ6/3,-SQ3/3,     0),
38
           new Static3D(     0,+SQ3/3,+SQ6/3), new Static3D(     0,-SQ3/3,-SQ6/3),
39
           new Static3D(     0,+SQ3/3,-SQ6/3), new Static3D(     0,-SQ3/3,+SQ6/3)
40
         };
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public MovementOctahedron(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
45
    {
46
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
// corner    edge
51
//   |       \ 0 /
52
// 2 | 0      \ /
53
//  / \      2 | 1
54
// / 1 \       |
55

  
56
  int returnPart(int type, int face, float[] touchPoint)
57
    {
58
    switch(type)
59
      {
60
      case TYPE_NOT_SPLIT   : return 0;
61

  
62
      case TYPE_SPLIT_EDGE  : float y1 = (face%2 == 0 ? touchPoint[1] : -touchPoint[1]);
63
                              float x1 = touchPoint[0];
64

  
65
                              boolean e0 = x1>0;
66
                              boolean e1 = y1>(+SQ3/3)*x1;
67
                              boolean e2 = y1>(-SQ3/3)*x1;
68

  
69
                              if(  e1 && e2 ) return 0;
70
                              if( !e1 && e0 ) return 1;
71
                              if( !e0 &&!e2 ) return 2;
72

  
73
      case TYPE_SPLIT_CORNER: float y2 = (face%2 == 0 ? touchPoint[1] : -touchPoint[1]);
74
                              float x2 = touchPoint[0];
75

  
76
                              boolean c0 = x2>0;
77
                              boolean c1 = y2>(+SQ3/3)*x2;
78
                              boolean c2 = y2>(-SQ3/3)*x2;
79

  
80
                              if(  c0 && c2 ) return 0;
81
                              if( !c1 &&!c2 ) return 1;
82
                              if( !c0 && c1 ) return 2;
83
      }
84

  
85
    return 0;
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  public float returnRotationFactor(int[] numLayers, int row)
91
    {
92
    return 1.0f;
93
    }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

  
97
  boolean isInsideFace(int face, float[] p)
98
    {
99
    float y = (face%2 == 0 ? p[1] : -p[1]);
100
    float x = p[0];
101
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
102
    }
103
}
src/main/java/org/distorted/objectlib/main/MovementTetrahedron.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

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

  
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
// Tetrahedral objects: map the 2D swipes of user's fingers to 3D rotations
26

  
27
public class MovementTetrahedron extends Movement
28
{
29
  private static final float DIST3D = SQ6/12;
30
  private static final float DIST2D = SQ3/6;
31

  
32
  private static final float[] D3D  = { DIST3D,DIST3D,DIST3D,DIST3D };
33

  
34
  public static final Static3D[] FACE_AXIS = new Static3D[]
35
         {
36
           new Static3D(     0,+SQ3/3,+SQ6/3),
37
           new Static3D(     0,+SQ3/3,-SQ6/3),
38
           new Static3D(-SQ6/3,-SQ3/3,     0),
39
           new Static3D(+SQ6/3,-SQ3/3,     0),
40
         };
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public MovementTetrahedron(Static3D[] rotAxis, float[][] cuts, boolean[][] rotatable, float size, int type, int[][][] enabled)
45
    {
46
    super(rotAxis, FACE_AXIS, cuts, rotatable, D3D, size, type, enabled);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50
// corner    edge
51
//   |       \ 0 /
52
// 2 | 0      \ /
53
//  / \      2 | 1
54
// / 1 \       |
55

  
56
  int returnPart(int type, int face, float[] touchPoint)
57
    {
58
    switch(type)
59
      {
60
      case TYPE_NOT_SPLIT   : return 0;
61

  
62
      case TYPE_SPLIT_EDGE  : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
63
                              float x1 = touchPoint[0];
64

  
65
                              boolean e0 = x1>0;
66
                              boolean e1 = y1>(+SQ3/3)*x1;
67
                              boolean e2 = y1>(-SQ3/3)*x1;
68

  
69
                              if(  e1 && e2 ) return 0;
70
                              if( !e1 && e0 ) return 1;
71
                              if( !e0 &&!e2 ) return 2;
72

  
73
      case TYPE_SPLIT_CORNER: float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]);
74
                              float x2 = touchPoint[0];
75

  
76
                              boolean c0 = x2>0;
77
                              boolean c1 = y2>(+SQ3/3)*x2;
78
                              boolean c2 = y2>(-SQ3/3)*x2;
79

  
80
                              if(  c0 && c2 ) return 0;
81
                              if( !c1 &&!c2 ) return 1;
82
                              if( !c0 && c1 ) return 2;
83
      }
84

  
85
    return 0;
86
    }
87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89
// Jing has nL=2
90

  
91
  public float returnRotationFactor(int[] numLayers, int row)
92
    {
93
    int numL = numLayers[0];
94

  
95
    return numL==2 ? 1.0f : ((float)numL)/(numL-row);
96
    }
97

  
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

  
100
  boolean isInsideFace(int face, float[] p)
101
    {
102
    float y = (face > 1 ? p[1] : -p[1]);
103
    float x = p[0];
104
    return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
105
    }
106
}
src/main/java/org/distorted/objectlib/main/Twisty12.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
public abstract class Twisty12 extends TwistyObject
30
{
31
  static final int MINX_LGREEN = 0xff53aa00;
32
  static final int MINX_PINK   = 0xfffd7ab7;
33
  static final int MINX_SANDY  = 0xffefd48b;
34
  static final int MINX_LBLUE  = 0xff00a2d7;
35
  static final int MINX_ORANGE = 0xffff6200;
36
  static final int MINX_VIOLET = 0xff7d59a4;
37
  static final int MINX_DGREEN = 0xff007a47;
38
  static final int MINX_DRED   = 0xffbd0000;
39
  static final int MINX_DBLUE  = 0xff1a29b2;
40
  static final int MINX_DYELLOW= 0xffffc400;
41
  static final int MINX_WHITE  = 0xffffffff;
42
  static final int MINX_GREY   = 0xff727c7b;
43

  
44
  static final int[] FACE_COLORS = new int[]
45
         {
46
           MINX_LGREEN, MINX_PINK   , MINX_SANDY , MINX_LBLUE,
47
           MINX_ORANGE, MINX_VIOLET , MINX_DGREEN, MINX_DRED ,
48
           MINX_DBLUE , MINX_DYELLOW, MINX_WHITE , MINX_GREY
49
         };
50

  
51
  static final int NUM_FACES = 12;
52
  static final int FOV = 30;
53
  static final float RATIO = 0.35f;
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public Twisty12(int[] numLayers, float realSize, Static4D quat, Static3D move, float scale, InputStream stream)
58
    {
59
    super(numLayers, realSize, quat, move, scale, stream);
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public final int getNumFaces()
65
    {
66
    return NUM_FACES;
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  public int getNumFaceColors()
72
    {
73
    return FACE_COLORS.length;
74
    }
75

  
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

  
78
  public int getColor(int face)
79
    {
80
    return FACE_COLORS[face];
81
    }
82

  
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

  
85
  public int getFOV()
86
    {
87
    return FOV;
88
    }
89

  
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

  
92
  public float getScreenRatio()
93
    {
94
    return RATIO;
95
    }
96
}
src/main/java/org/distorted/objectlib/main/Twisty4.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
public abstract class Twisty4 extends TwistyObject
30
{
31
  static final int[] FACE_COLORS = new int[]
32
         {
33
           COLOR_GREEN , COLOR_YELLOW,
34
           COLOR_BLUE  , COLOR_RED
35
         };
36

  
37
  static final int NUM_FACES = 4;
38
  static final int FOV = 60;
39
  static final float RATIO = 0.89f;
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public Twisty4(int[] numLayers, float realSize, Static4D quat, Static3D move, float scale, InputStream stream)
44
    {
45
    super(numLayers, realSize, quat, move, scale, stream);
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  public final int getNumFaces()
51
    {
52
    return NUM_FACES;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public int getNumFaceColors()
58
    {
59
    return FACE_COLORS.length;
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public int getColor(int face)
65
    {
66
    return FACE_COLORS[face];
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  public int getFOV()
72
    {
73
    return FOV;
74
    }
75

  
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

  
78
  public float getScreenRatio()
79
    {
80
    return RATIO;
81
    }
82
}
src/main/java/org/distorted/objectlib/main/Twisty6.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
public abstract class Twisty6 extends TwistyObject
30
{
31
  static final int[] FACE_COLORS = new int[]
32
         {
33
           COLOR_YELLOW, COLOR_WHITE,
34
           COLOR_BLUE  , COLOR_GREEN,
35
           COLOR_RED   , COLOR_ORANGE
36
         };
37

  
38
  static final int NUM_FACES = 6;
39
  static final int FOV = 60;
40
  static final float RATIO = 0.50f;
41

  
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

  
44
  public Twisty6(int[] numLayers, float realSize, Static4D quat, Static3D move, float scale, InputStream stream)
45
    {
46
    super(numLayers, realSize, quat, move, scale, stream);
47
    }
48

  
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

  
51
  public final int getNumFaces()
52
    {
53
    return NUM_FACES;
54
    }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  public int getNumFaceColors()
59
    {
60
    return FACE_COLORS.length;
61
    }
62

  
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

  
65
  public int getColor(int face)
66
    {
67
    return FACE_COLORS[face];
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  public int getFOV()
73
    {
74
    return FOV;
75
    }
76

  
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

  
79
  public float getScreenRatio()
80
    {
81
    return RATIO;
82
    }
83
}
src/main/java/org/distorted/objectlib/main/Twisty8.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.objectlib.main;
21

  
22
import java.io.InputStream;
23

  
24
import org.distorted.library.type.Static3D;
25
import org.distorted.library.type.Static4D;
26

  
27
///////////////////////////////////////////////////////////////////////////////////////////////////
28

  
29
public abstract class Twisty8 extends TwistyObject
30
{
31
  static final int[] FACE_COLORS = new int[]
32
         {
33
           COLOR_ORANGE, COLOR_VIOLET,
34
           COLOR_WHITE , COLOR_BLUE  ,
35
           COLOR_YELLOW, COLOR_RED   ,
36
           COLOR_GREEN , COLOR_GREY
37
         };
38

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff