예제 #1
0
        internal static FaceDir RotateBy(this FaceDir faceDir, Rotation r)
        {
            var f  = faceDir.Forward();
            var x1 = (int)f.x;
            var z1 = (int)f.z;

            var(x2, z2) = TopoArrayUtils.SquareRotateVector(x1, z1, r);
            if (x1 == x2 && z1 == z2)
            {
                return(faceDir);
            }
            if (x2 == 1)
            {
                return(FaceDir.Right);
            }
            if (x2 == -1)
            {
                return(FaceDir.Left);
            }
            if (z2 == 1)
            {
                return(FaceDir.Forward);
            }
            if (z2 == -1)
            {
                return(FaceDir.Back);
            }
            throw new System.Exception();
        }
예제 #2
0
 /// <summary>
 /// Rotates v about the y-axis by r.
 /// </summary>
 internal static Vector3Int Rotate(Rotation r, Vector3Int v)
 {
     (v.x, v.z) = TopoArrayUtils.SquareRotateVector(v.x, v.z, r);
     return(v);
 }