Revision 967c1d17
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/Movement4.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import static org.distorted.objects.TwistyObject.SQ2; |
|
23 |
|
|
24 | 22 |
import org.distorted.library.type.Static3D; |
25 | 23 |
|
26 | 24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
27 | 25 |
// Tetrahedral objects: map the 2D swipes of user's fingers to 3D rotations |
28 | 26 |
|
29 |
abstract class Movement4 extends Movement
|
|
27 |
class Movement4 extends Movement |
|
30 | 28 |
{ |
31 | 29 |
static final float DIST3D = SQ6/12; |
32 | 30 |
static final float DIST2D = SQ3/6; |
... | ... | |
41 | 39 |
|
42 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
43 | 41 |
|
44 |
Movement4(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int size) |
|
42 |
Movement4(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int size, int type, int[] numEnabled, int[][][] enabled)
|
|
45 | 43 |
{ |
46 |
super(rotAxis, FACE_AXIS, cuts, rotatable, DIST3D, size); |
|
44 |
super(rotAxis, FACE_AXIS, cuts, rotatable, DIST3D, size, type, numEnabled, enabled); |
|
45 |
} |
|
46 |
|
|
47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
48 |
// corner edge |
|
49 |
// | \ 0 / |
|
50 |
// 2 | 0 \ / |
|
51 |
// / \ 2 | 1 |
|
52 |
// / 1 \ | |
|
53 |
|
|
54 |
int returnPart(int type, int face, float[] touchPoint) |
|
55 |
{ |
|
56 |
switch(type) |
|
57 |
{ |
|
58 |
case TYPE_NOT_SPLIT : return 0; |
|
59 |
|
|
60 |
case TYPE_SPLIT_EDGE : float y1 = (face > 1 ? touchPoint[1] : -touchPoint[1]); |
|
61 |
float x1 = touchPoint[0]; |
|
62 |
|
|
63 |
boolean e0 = x1>0; |
|
64 |
boolean e1 = y1>(+SQ3/3)*x1; |
|
65 |
boolean e2 = y1>(-SQ3/3)*x1; |
|
66 |
|
|
67 |
if( e1 && e2 ) return 0; |
|
68 |
if( !e1 && e0 ) return 1; |
|
69 |
if( !e0 &&!e2 ) return 2; |
|
70 |
|
|
71 |
case TYPE_SPLIT_CORNER: float y2 = (face > 1 ? touchPoint[1] : -touchPoint[1]); |
|
72 |
float x2 = touchPoint[0]; |
|
73 |
|
|
74 |
boolean c0 = x2>0; |
|
75 |
boolean c1 = y2>(+SQ3/3)*x2; |
|
76 |
boolean c2 = y2>(-SQ3/3)*x2; |
|
77 |
|
|
78 |
if( c0 && c2 ) return 0; |
|
79 |
if( !c1 &&!c2 ) return 1; |
|
80 |
if( !c0 && c1 ) return 2; |
|
81 |
} |
|
82 |
|
|
83 |
return 0; |
|
47 | 84 |
} |
48 | 85 |
|
49 | 86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Do away with the last method in the object Movement classes. Remove the object Movement classes altogether.
From now on the implementation of a TwistyPuzzle is 100% data, no code at all.
Next step: make the implementation a (generated?) (XML?) file.