1 |
cc7dc72a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
1f9772f3
|
Leszek Koltunski
|
package org.distorted.objects;
|
21 |
cc7dc72a
|
Leszek Koltunski
|
|
22 |
cc99cf91
|
Leszek Koltunski
|
import org.distorted.library.type.Static3D;
|
23 |
|
|
|
24 |
cc7dc72a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
25 |
|
|
|
26 |
ca3300c3
|
Leszek Koltunski
|
class MovementPyraminx extends Movement
|
27 |
cc7dc72a
|
Leszek Koltunski
|
{
|
28 |
cc99cf91
|
Leszek Koltunski
|
static final float DIST3D = SQ6/12;
|
29 |
|
|
static final float DIST2D = SQ3/6;
|
30 |
|
|
|
31 |
|
|
static final Static3D[] FACE_AXIS = new Static3D[]
|
32 |
|
|
{
|
33 |
ac940e24
|
Leszek Koltunski
|
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 |
cc99cf91
|
Leszek Koltunski
|
};
|
38 |
cc7dc72a
|
Leszek Koltunski
|
|
39 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40 |
|
|
|
41 |
ca3300c3
|
Leszek Koltunski
|
MovementPyraminx()
|
42 |
dd65ead3
|
Leszek Koltunski
|
{
|
43 |
cc99cf91
|
Leszek Koltunski
|
super(TwistyPyraminx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
44 |
dd65ead3
|
Leszek Koltunski
|
}
|
45 |
|
|
|
46 |
ee39837d
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
47 |
|
|
|
48 |
1ded8771
|
Leszek Koltunski
|
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
|
49 |
ee39837d
|
Leszek Koltunski
|
{
|
50 |
1ded8771
|
Leszek Koltunski
|
return (int)(numLayers*offset/(SQ6/3));
|
51 |
ee39837d
|
Leszek Koltunski
|
}
|
52 |
|
|
|
53 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54 |
|
|
|
55 |
1ded8771
|
Leszek Koltunski
|
public float returnRotationFactor(int numLayers, int row)
|
56 |
ee39837d
|
Leszek Koltunski
|
{
|
57 |
1ded8771
|
Leszek Koltunski
|
return ((float)numLayers)/(numLayers-row);
|
58 |
ee39837d
|
Leszek Koltunski
|
}
|
59 |
|
|
|
60 |
cc7dc72a
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61 |
|
|
|
62 |
cc99cf91
|
Leszek Koltunski
|
boolean isInsideFace(int face, float[] p)
|
63 |
dd65ead3
|
Leszek Koltunski
|
{
|
64 |
ac940e24
|
Leszek Koltunski
|
float y = (face > 1 ? p[1] : -p[1]);
|
65 |
|
|
float x = p[0];
|
66 |
|
|
|
67 |
|
|
return (y >= -DIST2D) && (y <= DIST2D*(2-6*x)) && (y <= DIST2D*(2+6*x));
|
68 |
dd65ead3
|
Leszek Koltunski
|
}
|
69 |
fb377dae
|
Leszek Koltunski
|
|
70 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
71 |
|
|
|
72 |
|
|
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
|
73 |
|
|
{
|
74 |
|
|
enabled[0] = 3;
|
75 |
|
|
|
76 |
|
|
switch(face)
|
77 |
|
|
{
|
78 |
|
|
case 0: enabled[1]=1; enabled[2]=2; enabled[3]=3; break;
|
79 |
|
|
case 1: enabled[1]=0; enabled[2]=2; enabled[3]=3; break;
|
80 |
|
|
case 2: enabled[1]=0; enabled[2]=1; enabled[3]=3; break;
|
81 |
|
|
case 3: enabled[1]=0; enabled[2]=1; enabled[3]=2; break;
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
cc7dc72a
|
Leszek Koltunski
|
}
|