Project

General

Profile

« Previous | Next » 

Revision ef018c1b

Added by Leszek Koltunski over 2 years ago

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.

View differences:

src/main/java/org/distorted/objects/MovementDiamond.java
23 23

  
24 24
class MovementDiamond extends Movement8
25 25
{
26
  MovementDiamond()
26
  MovementDiamond(float[][] cuts, boolean[][] rotatable, int numLayers)
27 27
    {
28
    super(TwistyDiamond.ROT_AXIS);
29
    }
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
// We have either one of the four faces (1,3,4,6) which, when the retAxis are cast onto it, they
33
// point the right way (and so the triangle then spans from offset=-SQ3/6 to offset=+SQ3/3 with
34
// midpoint at SQ3/12) or one of the other face when the cast rotAxis are the wrong way round (and
35
// the triangle spans then from 0 to SQ3/2 with midpoint at SQ3/4).
36

  
37
  int computeRowFromOffset(int face, int axisIndex, int numLayers, float offset)
38
    {
39
    float off = ( face==1 || face==3 || face==4 || face==6 ) ? (offset+2*DIST2D) : (offset+DIST2D);
40
    return (int)(numLayers*off/(3*DIST2D));
28
    super(TwistyDiamond.ROT_AXIS,cuts,rotatable, numLayers);
41 29
    }
42 30

  
43 31
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff