void PlotGraph() { Vector3 p1, p2; Vector3 screenPos1, screenPos2; dataPointArray = PairDistributionFunction.PairDistributionAverage; if (dataPointArray.Length <= 1) { xSpacing = 0; } else { xSpacing = graphRect.width * canvasScale / (dataPointArray.Length - 1); } yMax = Mathf.Max(dataPointArray); if (yMax <= 0) { return; } for (int i = 0; i < dataPointArray.Length - 1; i++) { float d1 = (float)dataPointArray[i]; float d2 = (float)dataPointArray[i + 1]; float percent1 = d1 / yMax; float percent2 = d2 / yMax; float yVal1 = percent1 * graphHeight; float yVal2 = percent2 * graphHeight; screenPos1 = new Vector3(graphOrigin.x + (i * xSpacing), graphOrigin.y + yVal1, 5.0f); screenPos2 = new Vector3(screenPos1.x + xSpacing, graphOrigin.y + yVal2, 5.0f); //screen p1 = Camera.main.ScreenToWorldPoint(screenPos1); p2 = Camera.main.ScreenToWorldPoint(screenPos2); //Debug.Log(p1); StaticVariables.DrawLine(p1, p2, Color.white, Color.white, 0.015f, mat); } }
void OnPostRender() { if (StaticVariables.drawBondLines) { for (int i = 0; i < Atom.AllAtoms.Count; i++) { for (int j = i + 1; j < Atom.AllAtoms.Count; j++) { Atom currAtom = Atom.AllAtoms[i]; Atom neighborAtom = Atom.AllAtoms[j]; if ((currAtom.transform.position - neighborAtom.transform.position).magnitude < currAtom.BondDistance(neighborAtom)) { //draw a line from currAtom to atomNeighbor //if(bondColor == null)bondColor = Color.clear; StaticVariables.DrawLine(currAtom.transform.position, neighborAtom.transform.position, bondColor, bondColor, 0.05f, mat); } } } } }