Revision ff6c3ec3
Added by Leszek Koltunski 8 months ago
src/main/java/org/distorted/objectlib/main/TwistyObjectTheoretical.java | ||
---|---|---|
328 | 328 |
} |
329 | 329 |
} |
330 | 330 |
|
331 |
// Note that this is not necessarily correct in case of self-created shape-shifters, e.g. the |
|
332 |
// 3x3x5. This one is hollow inside, i.e. has only 8 cubits in the middle layers along the |
|
333 |
// longest ax! Result is: along this ax it appears to be completely bandaged. |
|
334 |
|
|
335 | 331 |
if( mMinimalCubiesInRow!=null ) |
336 | 332 |
{ |
337 | 333 |
int[] minC = mMinimalCubiesInRow[axisIndex]; |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedCuboid.java | ||
---|---|---|
245 | 245 |
@Override |
246 | 246 |
public int[][] getMinimalCubiesInRow() |
247 | 247 |
{ |
248 |
int[] numL = getNumLayers(); |
|
249 |
int x = numL[0]; |
|
250 |
int y = numL[1]; |
|
251 |
int z = numL[2]; |
|
252 |
int num = 0; |
|
253 |
|
|
254 |
if( ((x-y)%2)==0 && x!=y ) |
|
255 |
{ |
|
256 |
int m = Math.min(x,y); |
|
257 |
num = m*z; |
|
258 |
} |
|
259 |
if( ((x-z)%2)==0 && x!=z ) |
|
260 |
{ |
|
261 |
int m = Math.min(x,z); |
|
262 |
int n = m*y; |
|
263 |
if( num==0 || num>n ) num=n; |
|
264 |
} |
|
265 |
if( ((y-z)%2)==0 && y!=z ) |
|
266 |
{ |
|
267 |
int m = Math.min(y,z); |
|
268 |
int n = m*x; |
|
269 |
if( num==0 || num>n ) num=n; |
|
270 |
} |
|
271 |
|
|
272 |
if( num>0 ) |
|
273 |
{ |
|
274 |
int max = x>y ? Math.max(x,z) : Math.max(y,z); |
|
275 |
int min = x<y ? Math.min(x,z) : Math.min(y,z); |
|
276 |
int val = min==1 ? 1 : num; |
|
277 |
|
|
278 |
int[] m = new int[max]; |
|
279 |
for(int i=0; i<max; i++) m[i] = val; |
|
280 |
return new int[][]{m, m, m}; |
|
281 |
} |
|
282 |
|
|
283 |
return null; |
|
248 |
int[] nL = getNumLayers(); |
|
249 |
return TwistyCuboid.getMinimalCubiesInRow(nL[0],nL[1],nL[2]); |
|
284 | 250 |
} |
285 | 251 |
|
286 | 252 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java | ||
---|---|---|
80 | 80 |
return isAShapeshifter(numL) ? 0xff333333 : 0xff000000; |
81 | 81 |
} |
82 | 82 |
|
83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
84 |
|
|
85 |
@Override |
|
86 |
public float[][] returnRotationFactor() |
|
87 |
{ |
|
88 |
int[] len = possiblyShapeshifterNumLayers(); |
|
89 |
float[][] factor = new float[3][]; |
|
90 |
|
|
91 |
for(int ax=0; ax<3; ax++) |
|
92 |
{ |
|
93 |
int numL = len[ax]; |
|
94 |
factor[ax] = new float[numL]; |
|
95 |
for(int la=0; la<numL; la++) factor[ax][la] = 1.0f; |
|
96 |
} |
|
97 |
|
|
98 |
return factor; |
|
99 |
} |
|
100 |
|
|
83 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
84 | 102 |
|
85 | 103 |
@Override |
86 | 104 |
public int[][] getMinimalCubiesInRow() |
87 | 105 |
{ |
88 |
int[] numL = getNumLayers(); |
|
89 |
int x = numL[0]; |
|
90 |
int y = numL[1]; |
|
91 |
int z = numL[2]; |
|
92 |
int num = 0; |
|
106 |
int[] nL = getNumLayers(); |
|
107 |
return getMinimalCubiesInRow(nL[0],nL[1],nL[2]); |
|
108 |
} |
|
109 |
|
|
110 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
111 |
|
|
112 |
public static int[][] getMinimalCubiesInRow(int x, int y, int z) |
|
113 |
{ |
|
114 |
int numExt=0, numInt=0; |
|
93 | 115 |
|
94 | 116 |
if( ((x-y)%2)==0 && x!=y ) |
95 | 117 |
{ |
96 | 118 |
int m = Math.min(x,y); |
97 |
num = m*z; |
|
119 |
numExt = m*z; |
|
120 |
numInt = (m>2 && z>2) ? numExt - (m-2)*(z-2) : numExt; |
|
98 | 121 |
} |
99 | 122 |
if( ((x-z)%2)==0 && x!=z ) |
100 | 123 |
{ |
101 | 124 |
int m = Math.min(x,z); |
102 |
int n = m*y; |
|
103 |
if( num==0 || num>n ) num=n; |
|
125 |
int nE = m*y; |
|
126 |
int nI = (m>2 && y>2) ? nE - (m-2)*(y-2) : nE; |
|
127 |
if( numExt==0 || numExt>nE ) numExt=nE; |
|
128 |
if( numInt==0 || numInt>nI ) numInt=nI; |
|
104 | 129 |
} |
105 | 130 |
if( ((y-z)%2)==0 && y!=z ) |
106 | 131 |
{ |
107 | 132 |
int m = Math.min(y,z); |
108 |
int n = m*x; |
|
109 |
if( num==0 || num>n ) num=n; |
|
133 |
int nE = m*x; |
|
134 |
int nI = (m>2 && x>2) ? nE - (m-2)*(x-2) : nE; |
|
135 |
if( numExt==0 || numExt>nE ) numExt=nE; |
|
136 |
if( numInt==0 || numInt>nI ) numInt=nI; |
|
110 | 137 |
} |
111 | 138 |
|
112 |
if( num>0 ) |
|
139 |
if( numExt>0 )
|
|
113 | 140 |
{ |
114 | 141 |
int max = x>y ? Math.max(x,z) : Math.max(y,z); |
115 | 142 |
int min = x<y ? Math.min(x,z) : Math.min(y,z); |
116 |
int val = min==1 ? 1 : num; |
|
143 |
int valE = min==1 ? 1 : numExt; |
|
144 |
int valI = min==1 ? 1 : numInt; |
|
117 | 145 |
|
118 | 146 |
int[] m = new int[max]; |
119 |
for(int i=0; i<max; i++) m[i] = val; |
|
147 |
for(int i=1; i<max-1; i++) m[i] = valI; |
|
148 |
m[0] = m[max-1] = valE; |
|
120 | 149 |
return new int[][]{m, m, m}; |
121 | 150 |
} |
122 | 151 |
|
123 | 152 |
return null; |
124 | 153 |
} |
125 | 154 |
|
126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
|
|
128 |
@Override |
|
129 |
public float[][] returnRotationFactor() |
|
130 |
{ |
|
131 |
int[] len = possiblyShapeshifterNumLayers(); |
|
132 |
float[][] factor = new float[3][]; |
|
133 |
|
|
134 |
for(int ax=0; ax<3; ax++) |
|
135 |
{ |
|
136 |
int numL = len[ax]; |
|
137 |
factor[ax] = new float[numL]; |
|
138 |
for(int la=0; la<numL; la++) factor[ax][la] = 1.0f; |
|
139 |
} |
|
140 |
|
|
141 |
return factor; |
|
142 |
} |
|
143 |
|
|
144 | 155 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
145 | 156 |
|
146 | 157 |
private int[] possiblyShapeshifterNumLayers() |
Also available in: Unified diff
better minimalCubiesInRow in case of cuboids - take into account that the shapeshifters can be hollow inside if x>=3, y>=3, z>=3 (e.g. 3x3x5)