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
|
import static org.distorted.objects.TwistyMinx.C1;
|
24
|
import static org.distorted.objects.TwistyMinx.C2;
|
25
|
import static org.distorted.objects.TwistyMinx.LEN;
|
26
|
import static org.distorted.objects.FactoryCubit.SIN54;
|
27
|
import static org.distorted.objects.FactoryCubit.COS54;
|
28
|
import static org.distorted.objects.TwistyObject.SQ5;
|
29
|
|
30
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
31
|
|
32
|
class MovementMinx extends Movement
|
33
|
{
|
34
|
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/3;
|
35
|
static final float DIST2D = (0.5f*SIN54/COS54)/3;
|
36
|
|
37
|
static final Static3D[] FACE_AXIS = new Static3D[]
|
38
|
{
|
39
|
new Static3D( C2/LEN, C1/LEN, 0 ),
|
40
|
new Static3D( C2/LEN,-C1/LEN, 0 ),
|
41
|
new Static3D(-C2/LEN, C1/LEN, 0 ),
|
42
|
new Static3D(-C2/LEN,-C1/LEN, 0 ),
|
43
|
new Static3D( 0 , C2/LEN, C1/LEN ),
|
44
|
new Static3D( 0 , C2/LEN,-C1/LEN ),
|
45
|
new Static3D( 0 ,-C2/LEN, C1/LEN ),
|
46
|
new Static3D( 0 ,-C2/LEN,-C1/LEN ),
|
47
|
new Static3D( C1/LEN, 0 , C2/LEN ),
|
48
|
new Static3D( C1/LEN, 0 ,-C2/LEN ),
|
49
|
new Static3D(-C1/LEN, 0 , C2/LEN ),
|
50
|
new Static3D(-C1/LEN, 0 ,-C2/LEN )
|
51
|
};
|
52
|
|
53
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
|
55
|
MovementMinx()
|
56
|
{
|
57
|
super(TwistyMinx.ROT_AXIS, FACE_AXIS, DIST3D, DIST2D);
|
58
|
}
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
int computeRowFromOffset(int face, int size, float offset)
|
63
|
{
|
64
|
return offset<DIST2D ? 0:2;
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
public float returnRotationFactor(int size, int row)
|
70
|
{
|
71
|
return 1.0f;
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
// TODO; approximation
|
76
|
|
77
|
boolean isInsideFace(int face, float[] p)
|
78
|
{
|
79
|
return ( p[0]*p[0] + p[1]*p[1] <= 1/(4*COS54*COS54) );
|
80
|
}
|
81
|
|
82
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
83
|
|
84
|
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled)
|
85
|
{
|
86
|
enabled[0] = 5;
|
87
|
|
88
|
switch(face)
|
89
|
{
|
90
|
case 0:
|
91
|
case 3: enabled[1]=1; enabled[2]=2; enabled[3]=3; enabled[4]=4; enabled[5]=5; break;
|
92
|
case 1:
|
93
|
case 2: enabled[1]=0; enabled[2]=2; enabled[3]=3; enabled[4]=4; enabled[5]=5; break;
|
94
|
case 4:
|
95
|
case 7: enabled[1]=0; enabled[2]=1; enabled[3]=3; enabled[4]=4; enabled[5]=5; break;
|
96
|
case 5:
|
97
|
case 6: enabled[1]=0; enabled[2]=1; enabled[3]=2; enabled[4]=4; enabled[5]=5; break;
|
98
|
case 8:
|
99
|
case 11: enabled[1]=0; enabled[2]=1; enabled[3]=2; enabled[4]=3; enabled[5]=5; break;
|
100
|
case 9:
|
101
|
case 10: enabled[1]=0; enabled[2]=1; enabled[3]=2; enabled[4]=3; enabled[5]=4; break;
|
102
|
}
|
103
|
}
|
104
|
}
|