public bool ValueEquals(VecNd other) { if (other.Components == null || this.Components == null) // if either are null then return whether both are null { return((other.Components == null) && (this.Components == null)); } if (other.Components.Length != this.Components.Length) { return(false); } for (int i = 0; i < this.Components.Length; i++) { if (this.Components[i] != other.Components[i]) { return(false); } } return(true); }
public VertexObject(VecNd position) { this.position = position; }
internal IEnumerator PhaseToNewObjectAndSetMaterialColor(float[][] newVertexPositions, int[][] newEdgeVertexIds, int[][] newFaceVertexIds, Color newVertexColor) { var returnDurationA = 2f; var returnElapsedA = 0f; var currVertPositions = this.GetVertexLocations; var zeroVecNd = new VecNd(new double[currVertPositions[0].Components.Length]); var newVertPositionsA = Enumerable.Range(0, currVertPositions.Length).Select(x => zeroVecNd).ToArray(); while (returnElapsedA < returnDurationA) { float currDistance = Helpers.GetRotationProgress(returnElapsedA / returnDurationA, 3); var newPos = Enumerable.Range(0, currVertPositions.Length) .Select(i => newVertPositionsA[i] * currDistance + currVertPositions[i] * (1 - currDistance)).ToArray(); SetVertexLocations(newPos); yield return(null); returnElapsedA += Time.deltaTime; } yield return(null); LoadVerticesEdgesAndFaces(newVertexPositions.Select(x => new float[x.Length]).ToArray(), newEdgeVertexIds, newFaceVertexIds); IList <VertexObject> verts = this.GetVertexObjects(); for (int i = 0; i < verts.Count; i++) { verts[i].GetTransform().GetComponent <MeshRenderer>().material.color = newVertexColor; } yield return(null); var returnDurationB = 2f; var returnElapsedB = 0f; var newVecNdVertexPositionsB = newVertexPositions.Select(x => new VecNd(x.Select(a => (double)a).ToArray())).ToArray(); var zeroVecNdB = new VecNd(new double[newVecNdVertexPositionsB[0].Components.Length]); var oldVertPositionsB = Enumerable.Range(0, newVecNdVertexPositionsB.Length).Select(x => zeroVecNdB).ToArray(); while (returnElapsedB < returnDurationB) { float currDistance = Helpers.GetRotationProgress(returnElapsedB / returnDurationB, 3); var newPos = Enumerable.Range(0, oldVertPositionsB.Length) .Select(i => newVecNdVertexPositionsB[i] * currDistance + oldVertPositionsB[i] * (1 - currDistance)).ToArray(); SetVertexLocations(newPos); yield return(null); returnElapsedB += Time.deltaTime; } yield return(null); }