Revision be7c9190
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/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.objects; |
|
21 |
|
|
22 |
import static org.distorted.objects.TwistyMinx.C2; |
|
23 |
import static org.distorted.objects.TwistyMinx.COS54; |
|
24 |
import static org.distorted.objects.TwistyMinx.LEN; |
|
25 |
import static org.distorted.objects.TwistyMinx.SIN54; |
|
26 |
import static org.distorted.objects.TwistyObject.SQ5; |
|
27 |
|
|
28 |
import org.distorted.library.type.Static3D; |
|
29 |
|
|
30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
|
32 |
abstract class Movement12 extends Movement |
|
33 |
{ |
|
34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5); |
|
35 |
static final float DIST2D = (SIN54/COS54)/2; |
|
36 |
|
|
37 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
38 |
{ |
|
39 |
new Static3D( C2/LEN, SIN54/LEN, 0 ), |
|
40 |
new Static3D( C2/LEN,-SIN54/LEN, 0 ), |
|
41 |
new Static3D( -C2/LEN, SIN54/LEN, 0 ), |
|
42 |
new Static3D( -C2/LEN,-SIN54/LEN, 0 ), |
|
43 |
new Static3D( 0 , C2/LEN, SIN54/LEN ), |
|
44 |
new Static3D( 0 , C2/LEN,-SIN54/LEN ), |
|
45 |
new Static3D( 0 , -C2/LEN, SIN54/LEN ), |
|
46 |
new Static3D( 0 , -C2/LEN,-SIN54/LEN ), |
|
47 |
new Static3D( SIN54/LEN, 0 , C2/LEN ), |
|
48 |
new Static3D( SIN54/LEN, 0 , -C2/LEN ), |
|
49 |
new Static3D(-SIN54/LEN, 0 , C2/LEN ), |
|
50 |
new Static3D(-SIN54/LEN, 0 , -C2/LEN ) |
|
51 |
}; |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
Movement12(Static3D[] rotAxis) |
|
56 |
{ |
|
57 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
|
58 |
} |
|
59 |
|
|
60 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
61 |
|
|
62 |
public float returnRotationFactor(int numLayers, int row) |
|
63 |
{ |
|
64 |
return 1.0f; |
|
65 |
} |
|
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
// return angle (in radians) that the line connecting the center C of the pentagonal face and the |
|
69 |
// first vertex of the pentagon makes with a vertical line coming upwards from the center C. |
|
70 |
|
|
71 |
private float returnAngle(int face) |
|
72 |
{ |
|
73 |
switch(face) |
|
74 |
{ |
|
75 |
case 0: |
|
76 |
case 2: |
|
77 |
case 6: |
|
78 |
case 7: return 0.0f; |
|
79 |
case 1: |
|
80 |
case 3: |
|
81 |
case 4: |
|
82 |
case 5: return (float)(36*Math.PI/180); |
|
83 |
case 9: |
|
84 |
case 10: return (float)(54*Math.PI/180); |
|
85 |
case 8: |
|
86 |
case 11: return (float)(18*Math.PI/180); |
|
87 |
} |
|
88 |
|
|
89 |
return 0.0f; |
|
90 |
} |
|
91 |
|
|
92 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
93 |
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector |
|
94 |
// from the center of the coordinate system to P. |
|
95 |
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at |
|
96 |
// P' and going in the direction of V. |
|
97 |
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of |
|
98 |
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points |
|
99 |
// directly upwards, is 'point' on the left or the right of it? |
|
100 |
|
|
101 |
private boolean isOnTheLeft(float[] point, float distance, float angle) |
|
102 |
{ |
|
103 |
float sin = (float)Math.sin(angle); |
|
104 |
float cos = (float)Math.cos(angle); |
|
105 |
|
|
106 |
float vx = point[0] + sin*distance; |
|
107 |
float vy = point[1] - cos*distance; |
|
108 |
|
|
109 |
return vx*sin < vy*cos; |
|
110 |
} |
|
111 |
|
|
112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
113 |
// Return 1,2,3,4,5 - the vertex of the pentagon to which point 'point' is the closest, if the |
|
114 |
// 'point' is inside the pentagon - or 0 otherwise. |
|
115 |
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00. |
|
116 |
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the |
|
117 |
// pentagon. |
|
118 |
// Distance from the center to a vertex of the pentagon = 1/(6*COS54) |
|
119 |
|
|
120 |
int returnPartOfThePentagon(float[] point, int face) |
|
121 |
{ |
|
122 |
float angle = returnAngle(face); |
|
123 |
float A = (float)(Math.PI/5); |
|
124 |
|
|
125 |
for(int i=0; i<5; i++) |
|
126 |
{ |
|
127 |
if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return 0; |
|
128 |
} |
|
129 |
|
|
130 |
if( isOnTheLeft(point, 0, 2.5f*A-angle) ) |
|
131 |
{ |
|
132 |
if( isOnTheLeft(point, 0, 3.5f*A-angle) ) |
|
133 |
{ |
|
134 |
return isOnTheLeft(point, 0, 5.5f*A-angle) ? 4 : 5; |
|
135 |
} |
|
136 |
else return 1; |
|
137 |
} |
|
138 |
else |
|
139 |
{ |
|
140 |
if( isOnTheLeft(point, 0, 4.5f*A-angle) ) |
|
141 |
{ |
|
142 |
return 3; |
|
143 |
} |
|
144 |
else |
|
145 |
{ |
|
146 |
return isOnTheLeft(point, 0, 6.5f*A-angle) ? 2 : 1; |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
152 |
|
|
153 |
boolean isInsideFace(int face, float[] p) |
|
154 |
{ |
|
155 |
return returnPartOfThePentagon(p,face) > 0; |
|
156 |
} |
|
157 |
} |
src/main/java/org/distorted/objects/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.objects; |
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
|
|
24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
|
26 |
abstract class Movement4 extends Movement |
|
27 |
{ |
|
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 |
Movement4(Static3D[] rotAxis) |
|
42 |
{ |
|
43 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
|
44 |
} |
|
45 |
|
|
46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
|
48 |
public float returnRotationFactor(int numLayers, int row) |
|
49 |
{ |
|
50 |
return ((float)numLayers)/(numLayers-row); |
|
51 |
} |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
boolean isInsideFace(int face, float[] p) |
|
56 |
{ |
|
57 |
float y = (face > 1 ? p[1] : -p[1]); |
|
58 |
float x = p[0]; |
|
59 |
return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x)); |
|
60 |
} |
|
61 |
} |
src/main/java/org/distorted/objects/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.objects; |
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
|
|
24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
|
26 |
abstract class Movement6 extends Movement |
|
27 |
{ |
|
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 |
Movement6(Static3D[] rotAxis) |
|
41 |
{ |
|
42 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
|
43 |
} |
|
44 |
|
|
45 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
46 |
|
|
47 |
public float returnRotationFactor(int numLayers, int row) |
|
48 |
{ |
|
49 |
return 1.0f; |
|
50 |
} |
|
51 |
|
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
boolean isInsideFace(int face, float[] p) |
|
55 |
{ |
|
56 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
57 |
} |
|
58 |
} |
src/main/java/org/distorted/objects/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.objects; |
|
21 |
|
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
|
|
24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
|
26 |
abstract class Movement8 extends Movement |
|
27 |
{ |
|
28 |
static final float DIST3D = SQ6/6; |
|
29 |
static final float DIST2D = SQ3/6; |
|
30 |
|
|
31 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
32 |
{ |
|
33 |
new Static3D(+SQ6/3,+SQ3/3, 0), new Static3D(-SQ6/3,-SQ3/3, 0), |
|
34 |
new Static3D(-SQ6/3,+SQ3/3, 0), new Static3D(+SQ6/3,-SQ3/3, 0), |
|
35 |
new Static3D( 0,+SQ3/3,+SQ6/3), new Static3D( 0,-SQ3/3,-SQ6/3), |
|
36 |
new Static3D( 0,+SQ3/3,-SQ6/3), new Static3D( 0,-SQ3/3,+SQ6/3) |
|
37 |
}; |
|
38 |
|
|
39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
40 |
|
|
41 |
Movement8(Static3D[] rotAxis) |
|
42 |
{ |
|
43 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
|
44 |
} |
|
45 |
|
|
46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
47 |
|
|
48 |
public float returnRotationFactor(int numLayers, int row) |
|
49 |
{ |
|
50 |
return 1.0f; |
|
51 |
} |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
|
|
55 |
boolean isInsideFace(int face, float[] p) |
|
56 |
{ |
|
57 |
float y = (face%2 == 0 ? p[1] : -p[1]); |
|
58 |
float x = p[0]; |
|
59 |
return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x)); |
|
60 |
} |
|
61 |
} |
src/main/java/org/distorted/objects/MovementCube.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 MovementCube extends Movement |
|
24 |
class MovementCube extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementCube() |
41 | 27 |
{ |
42 |
super(TwistyCube.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyCube.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return (int)(numLayers*offset); |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
60 |
|
|
61 |
boolean isInsideFace(int face, float[] p) |
|
62 |
{ |
|
63 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
64 |
} |
|
65 |
|
|
66 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
67 | 39 |
|
68 | 40 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementDiamond.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 MovementDiamond extends Movement |
|
24 |
class MovementDiamond extends Movement8
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = SQ6/6; |
|
29 |
static final float DIST2D = SQ3/6; |
|
30 |
|
|
31 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
32 |
{ |
|
33 |
new Static3D(+SQ6/3,+SQ3/3, 0), new Static3D(-SQ6/3,-SQ3/3, 0), |
|
34 |
new Static3D(-SQ6/3,+SQ3/3, 0), new Static3D(+SQ6/3,-SQ3/3, 0), |
|
35 |
new Static3D( 0,+SQ3/3,+SQ6/3), new Static3D( 0,-SQ3/3,-SQ6/3), |
|
36 |
new Static3D( 0,+SQ3/3,-SQ6/3), new Static3D( 0,-SQ3/3,+SQ6/3) |
|
37 |
}; |
|
38 |
|
|
39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
40 |
|
|
41 | 26 |
MovementDiamond() |
42 | 27 |
{ |
43 |
super(TwistyDiamond.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyDiamond.ROT_AXIS); |
|
44 | 29 |
} |
45 | 30 |
|
46 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
55 | 40 |
return (int)(2*numLayers*off); |
56 | 41 |
} |
57 | 42 |
|
58 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
59 |
|
|
60 |
public float returnRotationFactor(int numLayers, int row) |
|
61 |
{ |
|
62 |
return 1.0f; |
|
63 |
} |
|
64 |
|
|
65 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
66 |
|
|
67 |
boolean isInsideFace(int face, float[] p) |
|
68 |
{ |
|
69 |
float y = (face%2 == 0 ? p[1] : -p[1]); |
|
70 |
float x = p[0]; |
|
71 |
|
|
72 |
return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x)); |
|
73 |
} |
|
74 |
|
|
75 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
76 | 44 |
|
77 | 45 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementDino.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 MovementDino extends Movement |
|
24 |
class MovementDino extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
|
40 | 27 |
MovementDino() |
41 | 28 |
{ |
42 |
super(TwistyDino.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
29 |
super(TwistyDino.ROT_AXIS); |
|
43 | 30 |
} |
44 | 31 |
|
45 | 32 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 36 |
return offset<DIST2D ? 0:2; |
50 | 37 |
} |
51 | 38 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 39 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 40 |
// _____________ |
61 | 41 |
// | \ 0 / | |
... | ... | |
74 | 54 |
else return p1 ? 1:2; |
75 | 55 |
} |
76 | 56 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
boolean isInsideFace(int face, float[] p) |
|
80 |
{ |
|
81 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
82 |
} |
|
83 |
|
|
84 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 58 |
|
86 | 59 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementHelicopter.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 MovementHelicopter extends Movement |
|
24 |
class MovementHelicopter extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementHelicopter() |
41 | 27 |
{ |
42 |
super(TwistyHelicopter.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyHelicopter.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return offset<DIST2D ? 0:2; |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 39 |
// _____________ |
61 | 40 |
// | | | |
... | ... | |
74 | 53 |
else return p1 ? 3:2; |
75 | 54 |
} |
76 | 55 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
boolean isInsideFace(int face, float[] p) |
|
80 |
{ |
|
81 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
82 |
} |
|
83 |
|
|
84 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 57 |
|
86 | 58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementIvy.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 MovementIvy extends Movement |
|
24 |
class MovementIvy extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementIvy() |
41 | 27 |
{ |
42 |
super(TwistyIvy.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyIvy.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return offset<DIST2D ? 0:1; |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 39 |
// faces 0,1,2,3 --> / |
61 | 40 |
// faces 4,5 --> \ |
... | ... | |
66 | 45 |
else return touchPoint[1] >= touchPoint[0]; |
67 | 46 |
} |
68 | 47 |
|
69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
70 |
|
|
71 |
boolean isInsideFace(int face, float[] p) |
|
72 |
{ |
|
73 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
74 |
} |
|
75 |
|
|
76 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
77 | 49 |
// 0 +++ |
78 | 50 |
// 1 ++- |
src/main/java/org/distorted/objects/MovementJing.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
|
|
24 | 22 |
import static org.distorted.objects.TwistyJing.F; |
25 | 23 |
|
26 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
27 | 25 |
|
28 |
class MovementJing extends Movement |
|
26 |
class MovementJing extends Movement4
|
|
29 | 27 |
{ |
30 |
static final float DIST3D = SQ6/12; |
|
31 |
static final float DIST2D = SQ3/6; |
|
32 |
|
|
33 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
34 |
{ |
|
35 |
new Static3D( 0,+SQ3/3,+SQ6/3), |
|
36 |
new Static3D( 0,+SQ3/3,-SQ6/3), |
|
37 |
new Static3D(-SQ6/3,-SQ3/3, 0), |
|
38 |
new Static3D(+SQ6/3,-SQ3/3, 0), |
|
39 |
}; |
|
40 |
|
|
41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
42 |
|
|
43 | 28 |
MovementJing() |
44 | 29 |
{ |
45 |
super(TwistyJing.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
30 |
super(TwistyJing.ROT_AXIS); |
|
46 | 31 |
} |
47 | 32 |
|
48 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
52 | 37 |
return offset < (SQ3/4)*F ? 0:1; |
53 | 38 |
} |
54 | 39 |
|
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 |
float y = (face > 1 ? p[1] : -p[1]); |
|
67 |
float x = p[0]; |
|
68 |
return (y >= -DIST2D) && (y <= 2*DIST2D-SQ3*x) && (y <= 2*DIST2D+SQ3*x); |
|
69 |
} |
|
70 |
|
|
71 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
72 | 41 |
|
73 | 42 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementMinx.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import org.distorted.library.type.Static3D; |
|
23 |
import static org.distorted.objects.TwistyMinx.C2; |
|
24 |
import static org.distorted.objects.TwistyMinx.LEN; |
|
25 |
import static org.distorted.objects.TwistyMinx.SIN54; |
|
26 |
import static org.distorted.objects.TwistyMinx.COS54; |
|
27 |
import static org.distorted.objects.TwistyObject.SQ5; |
|
28 |
|
|
29 | 22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 23 |
|
31 |
class MovementMinx extends Movement |
|
24 |
class MovementMinx extends Movement12
|
|
32 | 25 |
{ |
33 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5); |
|
34 |
static final float DIST2D = (SIN54/COS54)/2; |
|
35 |
|
|
36 |
static final Static3D[] FACE_AXIS = new Static3D[] |
|
37 |
{ |
|
38 |
new Static3D( C2/LEN, SIN54/LEN, 0 ), |
|
39 |
new Static3D( C2/LEN,-SIN54/LEN, 0 ), |
|
40 |
new Static3D( -C2/LEN, SIN54/LEN, 0 ), |
|
41 |
new Static3D( -C2/LEN,-SIN54/LEN, 0 ), |
|
42 |
new Static3D( 0 , C2/LEN, SIN54/LEN ), |
|
43 |
new Static3D( 0 , C2/LEN,-SIN54/LEN ), |
|
44 |
new Static3D( 0 , -C2/LEN, SIN54/LEN ), |
|
45 |
new Static3D( 0 , -C2/LEN,-SIN54/LEN ), |
|
46 |
new Static3D( SIN54/LEN, 0 , C2/LEN ), |
|
47 |
new Static3D( SIN54/LEN, 0 , -C2/LEN ), |
|
48 |
new Static3D(-SIN54/LEN, 0 , C2/LEN ), |
|
49 |
new Static3D(-SIN54/LEN, 0 , -C2/LEN ) |
|
50 |
}; |
|
51 |
|
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 | 26 |
MovementMinx() |
55 | 27 |
{ |
56 |
super(TwistyMinx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyMinx.ROT_AXIS); |
|
57 | 29 |
} |
58 | 30 |
|
59 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
77 | 49 |
return 0; |
78 | 50 |
} |
79 | 51 |
|
80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
81 |
|
|
82 |
public float returnRotationFactor(int numLayers, int row) |
|
83 |
{ |
|
84 |
return 1.0f; |
|
85 |
} |
|
86 |
|
|
87 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
88 |
// return angle (in radians) that the line connecting the center C of the pentagonal face and the |
|
89 |
// first vertex of the pentagon makes with a vertical line coming upwards from the center C. |
|
90 |
|
|
91 |
private float returnAngle(int face) |
|
92 |
{ |
|
93 |
switch(face) |
|
94 |
{ |
|
95 |
case 0: |
|
96 |
case 2: |
|
97 |
case 6: |
|
98 |
case 7: return 0.0f; |
|
99 |
case 1: |
|
100 |
case 3: |
|
101 |
case 4: |
|
102 |
case 5: return (float)(36*Math.PI/180); |
|
103 |
case 9: |
|
104 |
case 10: return (float)(54*Math.PI/180); |
|
105 |
case 8: |
|
106 |
case 11: return (float)(18*Math.PI/180); |
|
107 |
} |
|
108 |
|
|
109 |
return 0.0f; |
|
110 |
} |
|
111 |
|
|
112 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
113 |
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector |
|
114 |
// from the center of the coordinate system to P. |
|
115 |
// Let P' be the point defined by polar (distance,angle+PI/2). Let Lh be the half-line starting at |
|
116 |
// P' and going in the direction of V. |
|
117 |
// Return true iff point 'point' lies on the left of Lh, i.e. when we rotate (using the center of |
|
118 |
// the coordinate system as the center of rotation) 'point' and Lh in such a way that Lh points |
|
119 |
// directly upwards, is 'point' on the left or the right of it? |
|
120 |
|
|
121 |
private boolean isOnTheLeft(float[] point, float distance, float angle) |
|
122 |
{ |
|
123 |
float sin = (float)Math.sin(angle); |
|
124 |
float cos = (float)Math.cos(angle); |
|
125 |
|
|
126 |
float vx = point[0] + sin*distance; |
|
127 |
float vy = point[1] - cos*distance; |
|
128 |
|
|
129 |
return vx*sin < vy*cos; |
|
130 |
} |
|
131 |
|
|
132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 |
// Return 1,2,3,4,5 - the vertex of the pentagon to which point 'point' is the closest, if the |
|
134 |
// 'point' is inside the pentagon - or 0 otherwise. |
|
135 |
// The 'first' vertex is the one we meet the first when we rotate clockwise starting from 12:00. |
|
136 |
// This vertex makes angle 'returnAngle()' with the line coming out upwards from the center of the |
|
137 |
// pentagon. |
|
138 |
// Distance from the center to a vertex of the pentagon = 1/(6*COS54) |
|
139 |
|
|
140 |
private int returnPartOfThePentagon(float[] point, int face) |
|
141 |
{ |
|
142 |
float angle = returnAngle(face); |
|
143 |
float A = (float)(Math.PI/5); |
|
144 |
|
|
145 |
for(int i=0; i<5; i++) |
|
146 |
{ |
|
147 |
if( isOnTheLeft(point, DIST2D, (9-2*i)*A-angle) ) return 0; |
|
148 |
} |
|
149 |
|
|
150 |
if( isOnTheLeft(point, 0, 2.5f*A-angle) ) |
|
151 |
{ |
|
152 |
if( isOnTheLeft(point, 0, 3.5f*A-angle) ) |
|
153 |
{ |
|
154 |
return isOnTheLeft(point, 0, 5.5f*A-angle) ? 4 : 5; |
|
155 |
} |
|
156 |
else return 1; |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
160 |
if( isOnTheLeft(point, 0, 4.5f*A-angle) ) |
|
161 |
{ |
|
162 |
return 3; |
|
163 |
} |
|
164 |
else |
|
165 |
{ |
|
166 |
return isOnTheLeft(point, 0, 6.5f*A-angle) ? 2 : 1; |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
172 |
|
|
173 |
boolean isInsideFace(int face, float[] p) |
|
174 |
{ |
|
175 |
return returnPartOfThePentagon(p,face) > 0; |
|
176 |
} |
|
177 |
|
|
178 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
179 | 53 |
|
180 | 54 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
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) |
src/main/java/org/distorted/objects/MovementRedi.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 MovementRedi extends Movement |
|
24 |
class MovementRedi extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementRedi() |
41 | 27 |
{ |
42 |
super(TwistyRedi.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyRedi.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return offset<DIST2D ? 0:2; |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 39 |
// _____________ |
61 | 40 |
// | \ 0 / | |
... | ... | |
74 | 53 |
else return p1 ? 1:2; |
75 | 54 |
} |
76 | 55 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
boolean isInsideFace(int face, float[] p) |
|
80 |
{ |
|
81 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
82 |
} |
|
83 |
|
|
84 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 57 |
|
86 | 58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementRex.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 MovementRex extends Movement |
|
24 |
class MovementRex extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementRex() |
41 | 27 |
{ |
42 |
super(TwistyRex.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistyRex.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return offset<DIST2D ? 0:2; |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 39 |
// _____________ |
61 | 40 |
// | \ 0 / | |
... | ... | |
74 | 53 |
else return p1 ? 1:2; |
75 | 54 |
} |
76 | 55 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
boolean isInsideFace(int face, float[] p) |
|
80 |
{ |
|
81 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
82 |
} |
|
83 |
|
|
84 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 57 |
|
86 | 58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementSkewb.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 MovementSkewb extends Movement |
|
24 |
class MovementSkewb extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementSkewb() |
41 | 27 |
{ |
42 |
super(TwistySkewb.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistySkewb.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
49 | 35 |
return offset<DIST2D ? 0:numLayers-1; |
50 | 36 |
} |
51 | 37 |
|
52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
53 |
|
|
54 |
public float returnRotationFactor(int numLayers, int row) |
|
55 |
{ |
|
56 |
return 1.0f; |
|
57 |
} |
|
58 |
|
|
59 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 39 |
// _____________ |
61 | 40 |
// | \ 0 / | |
... | ... | |
74 | 53 |
else return p1 ? 1:2; |
75 | 54 |
} |
76 | 55 |
|
77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
78 |
|
|
79 |
boolean isInsideFace(int face, float[] p) |
|
80 |
{ |
|
81 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D ); |
|
82 |
} |
|
83 |
|
|
84 | 56 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 57 |
|
86 | 58 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
src/main/java/org/distorted/objects/MovementSquare.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 MovementSquare extends Movement |
|
24 |
class MovementSquare extends Movement6
|
|
27 | 25 |
{ |
28 |
static final float DIST3D = 0.5f; |
|
29 |
static final float DIST2D = 0.5f; |
|
30 |
|
|
31 |
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 | 26 |
MovementSquare() |
41 | 27 |
{ |
42 |
super(TwistySquare.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
|
28 |
super(TwistySquare.ROT_AXIS); |
|
43 | 29 |
} |
44 | 30 |
|
45 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Abstract out some methods from the Movement classes. only two remain now: rowFromOffset and enabledAxis.