Revision ef018c1b
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/Movement.java | ||
---|---|---|
247 | 247 |
output[1] = v0*y0 + v1*y1 + v2*y2; |
248 | 248 |
} |
249 | 249 |
|
250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
|
|
252 |
float[] computeBorder(float scale, float[] cuts, boolean[] rotatable) |
|
253 |
{ |
|
254 |
int len = cuts.length; |
|
255 |
float[] border = new float[len]; |
|
256 |
|
|
257 |
for(int i=0; i<len; i++) |
|
258 |
{ |
|
259 |
if( !rotatable[i] ) |
|
260 |
{ |
|
261 |
border[i] = i>0 ? border[i-1] : -Float.MAX_VALUE; |
|
262 |
} |
|
263 |
else |
|
264 |
{ |
|
265 |
if( rotatable[i+1] ) border[i] = scale*cuts[i]; |
|
266 |
else |
|
267 |
{ |
|
268 |
int found = -1; |
|
269 |
|
|
270 |
for(int j=i+2; j<=len; j++) |
|
271 |
{ |
|
272 |
if( rotatable[j] ) |
|
273 |
{ |
|
274 |
found=j; |
|
275 |
break; |
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
border[i] = found>0 ? scale*(cuts[i]+cuts[found-1])/2 : Float.MAX_VALUE; |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
return border; |
|
285 |
} |
|
286 |
|
|
287 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
288 |
|
|
289 |
float[][] computeBorders(float coeff, float[][] cuts, boolean[][] rotatable) |
|
290 |
{ |
|
291 |
int numCuts = cuts.length; |
|
292 |
float[][] borders = new float[numCuts][]; |
|
293 |
|
|
294 |
for(int i=0; i<numCuts; i++) |
|
295 |
{ |
|
296 |
borders[i] = computeBorder(coeff,cuts[i],rotatable[i]); |
|
297 |
} |
|
298 |
|
|
299 |
return borders; |
|
300 |
} |
|
301 |
|
|
250 | 302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
251 | 303 |
// PUBLIC API |
252 | 304 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.