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)); } }
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; } }
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); }
/// <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); }
// 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!"); } }
/// <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); }