Revision ef018c1b
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/Movement8.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import static org.distorted.objects.TwistyObject.SQ2; |
|
23 |
|
|
22 | 24 |
import org.distorted.library.type.Static3D; |
23 | 25 |
|
24 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
37 | 39 |
new Static3D( 0,+SQ3/3,-SQ6/3), new Static3D( 0,-SQ3/3,+SQ6/3) |
38 | 40 |
}; |
39 | 41 |
|
42 |
private final float[][] mTouchBorders; |
|
43 |
|
|
40 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
41 | 45 |
|
42 |
Movement8(Static3D[] rotAxis) |
|
46 |
Movement8(Static3D[] rotAxis,float[][] cuts, boolean[][] rotatable, int numLayers)
|
|
43 | 47 |
{ |
44 | 48 |
super(rotAxis, FACE_AXIS, DIST3D, DIST2D); |
49 |
float scale = (3*SQ2/4)/numLayers; // 3*SQ2/4 is 1/cos(dihedral-90) |
|
50 |
mTouchBorders = computeBorders(scale,cuts,rotatable); |
|
51 |
} |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
// We have either one of the four faces (1,3,4,6) which, when the retAxis are cast onto it, they |
|
55 |
// point the right way (and so the triangle then spans from offset=-SQ3/6 to offset=+SQ3/3 with |
|
56 |
// midpoint at SQ3/12) or one of the other face when the cast rotAxis are the wrong way round (and |
|
57 |
// the triangle spans then from 0 to SQ3/2 with midpoint at SQ3/4). |
|
58 |
// |
|
59 |
// This is only true if the rotAxis connect the centers of opposing faces! |
|
60 |
|
|
61 |
int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset) |
|
62 |
{ |
|
63 |
float off = ( face==1 || face==3 || face==4 || face==6 ) ? DIST2D/2 : -DIST2D/2; |
|
64 |
float[] borders = mTouchBorders[axisIndex]; |
|
65 |
int len = borders.length; |
|
66 |
|
|
67 |
for(int i=0; i<len; i++) |
|
68 |
{ |
|
69 |
if( offset+off<borders[i] ) return i; |
|
70 |
} |
|
71 |
|
|
72 |
return len; |
|
45 | 73 |
} |
46 | 74 |
|
47 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Abstract the next function, computeRowFromOffset(), out of the individual Movement classes.
Still two issues:
1) mysterious 1.5 multiplier in Movement12
2) in Movement8, moving the offset works only if the rotAxis are face-turning, i.e. they connect the centers of the opposing faces of the octahedron.