Revision 12313693
Added by Leszek Koltunski almost 5 years ago
| src/main/java/org/distorted/objects/FactoryCubit.java | ||
|---|---|---|
| 45 | 45 |
private static final float SQ5 = (float)Math.sqrt(5); |
| 46 | 46 |
private static final float SQ6 = (float)Math.sqrt(6); |
| 47 | 47 |
|
| 48 |
static final float SIN54 = (SQ5+1)/4; // sin(54 deg) |
|
| 49 |
static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4); // cos(54 deg) |
|
| 50 |
|
|
| 48 | 51 |
static final float MINX_C0 = (SQ5-1)/4; |
| 49 |
static final float MINX_C1 = (SQ5+1)/4; // sin(54 deg) |
|
| 50 |
static final float MINX_C3 = (float)(Math.sqrt(10-2*SQ5)/4); // cos(54 deg) |
|
| 51 | 52 |
static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle) |
| 52 | 53 |
static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle) |
| 53 | 54 |
static final float MINX_SC = 0.5f; |
| ... | ... | |
| 692 | 693 |
float X1= (SQ5+1)/8; |
| 693 | 694 |
float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4); |
| 694 | 695 |
float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8); |
| 695 |
float H = 0.5f*MINX_C1/MINX_C3;
|
|
| 696 |
float H = 0.5f* SIN54 /COS54 ;
|
|
| 696 | 697 |
float X2= MINX_SC*H*MINX_C5; |
| 697 | 698 |
float Y3= MINX_SC*H/(2*MINX_C4); |
| 698 | 699 |
float Y4= MINX_SC*H*(1/(2*MINX_C4) - MINX_C4); |
| ... | ... | |
| 1221 | 1222 |
{
|
| 1222 | 1223 |
VertexEffect[] effect = new VertexEffect[10]; |
| 1223 | 1224 |
|
| 1224 |
float H = 0.5f*(MINX_C1/MINX_C3);
|
|
| 1225 |
float H = 0.5f*(SIN54 /COS54 );
|
|
| 1225 | 1226 |
float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4); |
| 1226 | 1227 |
float Y2= H/(2*MINX_C4); |
| 1227 | 1228 |
float A = (float)(Math.acos(-SQ5/5)*180/Math.PI); // dihedral angle of a dedecahedron in degrees |
| ... | ... | |
| 1631 | 1632 |
VertexEffect[] effects = createVertexEffectsMinxCorner(); |
| 1632 | 1633 |
for( VertexEffect effect : effects ) mesh.apply(effect); |
| 1633 | 1634 |
|
| 1634 |
float A = (2*SQ3/3)*MINX_C1;
|
|
| 1635 |
float A = (2*SQ3/3)* SIN54;
|
|
| 1635 | 1636 |
float B = 0.4f; |
| 1636 |
float X = MINX_C5*MINX_C1*MINX_C3;
|
|
| 1637 |
float Y = MINX_C1*MINX_C1 - 0.5f;
|
|
| 1638 |
float Z = MINX_C4*MINX_C1*MINX_C3;
|
|
| 1637 |
float X = MINX_C5* SIN54 *COS54 ;
|
|
| 1638 |
float Y = SIN54 * SIN54 - 0.5f;
|
|
| 1639 |
float Z = MINX_C4* SIN54 *COS54 ;
|
|
| 1639 | 1640 |
|
| 1640 | 1641 |
Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B); |
| 1641 | 1642 |
|
| src/main/java/org/distorted/objects/Movement.java | ||
|---|---|---|
| 27 | 27 |
|
| 28 | 28 |
public abstract class Movement |
| 29 | 29 |
{
|
| 30 |
static final float SQ2 = (float)Math.sqrt(2); |
|
| 31 | 30 |
static final float SQ3 = (float)Math.sqrt(3); |
| 32 | 31 |
static final float SQ6 = (float)Math.sqrt(6); |
| 33 | 32 |
|
| 34 |
private int mLastTouchedFace, mNumFaceAxis; |
|
| 35 |
private float[] mPoint, mCamera, mTouch; |
|
| 36 |
private float[] mPoint2D, mMove2D; |
|
| 33 |
private final int mNumFaceAxis; |
|
| 34 |
private final float[] mPoint, mCamera, mTouch; |
|
| 35 |
private final float[] mPoint2D, mMove2D; |
|
| 36 |
private final int[] mEnabledRotAxis; |
|
| 37 |
private final float mDistanceCenterFace3D, mDistanceCenterFace2D; |
|
| 38 |
private final Static3D[] mFaceAxis; |
|
| 39 |
|
|
| 40 |
private int mLastTouchedFace; |
|
| 37 | 41 |
private float[][][] mCastedRotAxis; |
| 38 | 42 |
private Static4D[][] mCastedRotAxis4D; |
| 39 |
private int[] mEnabledRotAxis; |
|
| 40 |
private float mDistanceCenterFace3D, mDistanceCenterFace2D; |
|
| 41 |
private Static3D[] mFaceAxis; |
|
| 42 | 43 |
|
| 43 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 45 |
|
| src/main/java/org/distorted/objects/MovementMinx.java | ||
|---|---|---|
| 20 | 20 |
package org.distorted.objects; |
| 21 | 21 |
|
| 22 | 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; |
|
| 23 | 29 |
|
| 24 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 25 | 31 |
|
| 26 | 32 |
class MovementMinx extends Movement |
| 27 | 33 |
{
|
| 28 |
static final float DIST3D = 0.25f;
|
|
| 29 |
static final float DIST2D = 0.25f;
|
|
| 34 |
static final float DIST3D = (float)Math.sqrt(0.625f+0.275f*SQ5)/3;
|
|
| 35 |
static final float DIST2D = (0.5f*SIN54/COS54)/3;
|
|
| 30 | 36 |
|
| 31 | 37 |
static final Static3D[] FACE_AXIS = new Static3D[] |
| 32 | 38 |
{
|
| 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) |
|
| 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 ) |
|
| 36 | 51 |
}; |
| 37 | 52 |
|
| 38 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 46 | 61 |
|
| 47 | 62 |
int computeRowFromOffset(int face, int size, float offset) |
| 48 | 63 |
{
|
| 49 |
return offset<DIST2D ? 0:1;
|
|
| 64 |
return offset<DIST2D ? 0:2;
|
|
| 50 | 65 |
} |
| 51 | 66 |
|
| 52 | 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 57 | 72 |
} |
| 58 | 73 |
|
| 59 | 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 60 |
// faces 0,1,2,3 --> / |
|
| 61 |
// faces 4,5 --> \ |
|
| 62 |
|
|
| 63 |
private boolean isTopHalf(int face, float[] touchPoint) |
|
| 64 |
{
|
|
| 65 |
if( face==4 || face==5 ) return touchPoint[1] >=-touchPoint[0]; |
|
| 66 |
else return touchPoint[1] >= touchPoint[0]; |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 75 |
// TODO; approximation |
|
| 70 | 76 |
|
| 71 | 77 |
boolean isInsideFace(int face, float[] p) |
| 72 | 78 |
{
|
| 73 |
return ( p[0]<=DIST2D && p[0]>=-DIST2D && p[1]<=DIST2D && p[1]>=-DIST2D );
|
|
| 79 |
return ( p[0]*p[0] + p[1]*p[1] <= 1/(4*COS54*COS54) );
|
|
| 74 | 80 |
} |
| 75 | 81 |
|
| 76 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 77 |
// 0 +++ |
|
| 78 |
// 1 ++- |
|
| 79 |
// 2 +-+ |
|
| 80 |
// 3 +-- |
|
| 81 | 83 |
|
| 82 | 84 |
void computeEnabledAxis(int face, float[] touchPoint, int[] enabled) |
| 83 | 85 |
{
|
| 84 |
enabled[0] = 1; |
|
| 85 |
|
|
| 86 |
boolean isTop = isTopHalf(face,touchPoint); |
|
| 86 |
enabled[0] = 5; |
|
| 87 | 87 |
|
| 88 | 88 |
switch(face) |
| 89 | 89 |
{
|
| 90 |
case 0: enabled[1] = isTop ? 0:3; break; |
|
| 91 |
case 1: enabled[1] = isTop ? 2:1; break; |
|
| 92 |
case 2: enabled[1] = isTop ? 2:0; break; |
|
| 93 |
case 3: enabled[1] = isTop ? 1:3; break; |
|
| 94 |
case 4: enabled[1] = isTop ? 0:1; break; |
|
| 95 |
case 5: enabled[1] = isTop ? 2:3; break; |
|
| 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; |
|
| 96 | 102 |
} |
| 97 | 103 |
} |
| 98 | 104 |
} |
Also available in: Unified diff
Progress with the Kilominx movement (still not working)