示例#1
0
 public static void AssertSize(Vectord vector, uint size)
 {
     if (vector.DimensionCount != size)
     {
         throw new ArgumentException(string.Format("Vector invalid size, should be {0} but is {1}",
                                                   size, vector.DimensionCount));
     }
 }
示例#2
0
文件: Grid.cs 项目: busraerkoc/Tetris
 public void StoreShape(Shape shape)
 {
     foreach (Transform child in shape.transform)
     {
         Vector2 pos = Vectord.Round(child.position);
         board[(int)pos.x, (int)pos.y] = child;
     }
 }
示例#3
0
文件: Grid.cs 项目: busraerkoc/Tetris
 public bool CheckValidPosition(Shape shape)
 {
     foreach (Transform child in shape.transform)
     {
         Vector2 pos = Vectord.Round(child.position);
         if (!CheckGridBorder(pos))
         {
             return(false);
         }
         if (CheckIsFull((int)pos.x, (int)pos.y, shape))
         {
             return(false);
         }
     }
     return(true);
 }
示例#4
0
        /// <summary>
        /// The n-th column of vector.
        /// </summary>
        /// <param name="index">Column index.</param>
        /// <returns>Vector.</returns>
        public Vectord Column(uint index)
        {
            if (index >= elements.GetLength(1))
            {
                throw new ArgumentException("The dense matrix has only " + elements.GetLength(1)
                                            + " columns.");
            }

            // We construct vector.
            Vectord vector = new Vectord((uint)elements.GetLength(0));

            for (int i = 0; i < elements.GetLength(0); i++)
            {
                vector[(uint)i] = elements[i, index];
            }

            return(vector);
        }
示例#5
0
 // Start is called before the first frame update
 void Start()
 {
     grid              = GameObject.FindObjectOfType <Grid>();
     spawn             = GameObject.FindObjectOfType <Spawn>();
     nextDownTime      = Time.time + repeatRateDown;
     nextLeftRightTime = Time.time + repeatLeftRightTime;
     nextRotateTime    = Time.time + repeatRateRotate;
     if (spawn)
     {
         spawn.transform.position = Vectord.Round(spawn.transform.position);
         if (!activeShape)
         {
             //activeShape = spawn.GetRandomShape();
             activeShape = spawn.SpawnShape();
         }
     }
     else
     {
         Debug.LogWarning("WARNING! There is no spawner defined!");
     }
 }
示例#6
0
 /// <summary>
 /// Solves the system.
 /// </summary>
 /// <param name="S">The matrix.</param>
 /// <param name="C">Constants.</param>
 /// <returns></returns>
 public static Vectord SolveSystem(Matrix.DenseMatrixd S, Vectord C)
 {
     return(S.Inverse * C);
 }