// Use this for initialization void Start() { calculator = new CalculatorMtr(-5, -5, 5, 5, 0.05f); calculatory = new CalculatorMtr(-5, -5, 5, 5, 0.01f); calculatort = new Calculator4D(-5, -5, -5, 5, 5, 5, 0.05f); cw.init(-5, -5, -5, 5, 5, 5, 0.05f); pi = new ParticleIllustration(system); pi2 = new ParticleIllustration(linesystem, Color.black); GameObject go = GameObject.FindWithTag("InputText"); tm = go.GetComponent <TextMesh>(); calcubase = new Calculator(); Debug.Log(calcubase.calculate("sin(xy)", 1.655f, -3.439f)); Debug.Log(Mathf.Sin(1.655f * (-3.439f))); }
private void Update() { Vector3 oldPos = this.transform.position; FollowBoundingBox(true); Vector3 expectedPos = this.transform.position; if (Vector3.Distance(expectedPos, generatedMesh.transform.position) > generatedMesh.transform.localScale.x * 18.0f) { this.transform.position = oldPos; } switch (State) { case AppBarStateEnum.Default: targetBarSize = new Vector3(numDefaultButtons * buttonWidth, buttonWidth, 1f); break; case AppBarStateEnum.Hidden: targetBarSize = new Vector3(numHiddenButtons * buttonWidth, buttonWidth, 1f); break; case AppBarStateEnum.Manipulation: targetBarSize = new Vector3(numManipulationButtons * buttonWidth, buttonWidth, 1f); break; default: throw new ArgumentOutOfRangeException(); } backgroundBar.transform.localScale = Vector3.Lerp(backgroundBar.transform.localScale, targetBarSize, 0.5f); if (Input.GetKeyDown(KeyCode.P)) { Calculator4D catmp = new Calculator4D(-5, -5, -5, 5, 5, 5, 0.1f); //catmp.calculate("z*z+2xyz-16"); cw.calculate("z*z+2xyz-16"); } if (Input.GetKeyDown(KeyCode.O)) { Calculator4D catmp = new Calculator4D(-5, -5, -5, 5, 5, 5, 0.1f); //catmp.calculate("z*z+2xyz-16"); cw.calculatevec("pow(x,3)+pow(y,3)-6xy"); } List <List <float> > cwvecret; if ((cwvecret = cw.getCalcuResultvec()) != null) { pi.initialParticle(); for (int i = 0; i <= cw.sampleFreqy * 10 - 1; i += 1) { for (int j = 0; j <= cw.sampleFreqx * 10 - 1; j += 1) { //Debug.Log("herej" + j); if (float.IsNaN(cwvecret[i][j])) { continue; } float devi = Mathf.Abs(cwvecret[i][j]); if (devi <= cw.gap / 10 * 25) { if (devi <= Mathf.Abs(cwvecret[i][j - 1 >= 0 ? (j - 1) : 0]) && devi <= Mathf.Abs(cwvecret[i][j + 1 < cw.sampleFreqx * 10 ? (j + 1) : cw.sampleFreqx * 10 - 1])) { Vector3 posi = new Vector3((cw.xMin + cw.gap / 10 * i), (cw.yMin + cw.gap / 10 * j), 0); pi.drawParticle(posi); } else if (devi <= Mathf.Abs(cwvecret[i - 1 >= 0 ? (i - 1) : 0][j]) && devi <= Mathf.Abs(cwvecret[i + 1 < cw.sampleFreqy * 10 ? (i + 1) : cw.sampleFreqy * 10 - 1][j])) { Vector3 posi = new Vector3((cw.xMin + cw.gap / 10 * i), (cw.yMin + cw.gap / 10 * j), 0); pi.drawParticle(posi); } } } } pi.endDraw(); } List <List <List <float> > > cwret; if ((cwret = cw.getCalcuResult()) != null) { //todo destroy the inform Debug.Log("here"); pi.initialParticle(); for (int i = 2; i <= cw.sampleFreqz - 2; i += 1) { for (int j = 2; j <= cw.sampleFreqy - 2; j += 1) { for (int k = 2; k < cw.sampleFreqx - 2; k++) { float devi = Mathf.Abs(cwret[i][j][k]); if (float.IsNaN(cwret[i][j][k])) { continue; } if (devi <= cw.gap * 4) { if (devi <= Mathf.Abs(cwret[i][j][k - 1 >= 0 ? (k - 1) : 0]) && devi <= Mathf.Abs(cwret[i][j][k + 1 < cw.sampleFreqx ? (k + 1) : cw.sampleFreqx - 1])) { Vector3 posi = new Vector3((cw.xMin + cw.gap * i), (cw.zMin + cw.gap * k), (cw.yMin + cw.gap * j)); pi.drawParticle(posi); } else if (devi <= Mathf.Abs(cwret[i][j - 1 >= 0 ? (j - 1) : 0][k]) && devi <= Mathf.Abs(cwret[i][j + 1 < cw.sampleFreqy ? (j + 1) : cw.sampleFreqy - 1][k])) { Vector3 posi = new Vector3((cw.xMin + cw.gap * i), (cw.zMin + cw.gap * k), (cw.yMin + cw.gap * j)); pi.drawParticle(posi); } else if (devi <= Mathf.Abs(cwret[i - 1 >= 0 ? (i - 1) : 0][j][k]) && devi <= Mathf.Abs(cwret[i + 1 < cw.sampleFreqz ? (i + 1) : cw.sampleFreqz - 1][j][k])) { Vector3 posi = new Vector3((cw.xMin + cw.gap * i), (cw.zMin + cw.gap * k), (cw.yMin + cw.gap * j)); pi.drawParticle(posi); } } } } } pi.endDraw(); } }