Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            GameMath.Plot newCurve = new GameMath.Plot();

            //newCurve.Expr = "x**2";

            GameMath.Axes newGraph = new GameMath.Axes();
            newGraph.AddCurve(newCurve);

            newGraph.ResourceFolder.StrData = "Plot Figures";
            newGraph.FileName.StrData = "newGRAPH.png";

            newGraph.GenerateGrid();
            newGraph.GeneratePlot(0);

            UnityEditor.AssetDatabase.Refresh();

            plotSprites = Resources.LoadAll<Sprite>("Plot Figures");

            gameObject.GetComponent<SpriteRenderer>().sprite = plotSprites[counter];
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            GameMath.Plot newCurve = new GameMath.Plot();

            //newCurve.Expr = "x**2";

            GameMath.Axes newGraph = new GameMath.Axes();
            newGraph.AddCurve(newCurve);

            newGraph.ResourceFolder.StrData = "Plot Figures";
            newGraph.FileName.StrData       = "newGRAPH.png";

            newGraph.GenerateGrid();
            newGraph.GeneratePlot(0);

            UnityEditor.AssetDatabase.Refresh();

            plotSprites = Resources.LoadAll <Sprite>("Plot Figures");

            gameObject.GetComponent <SpriteRenderer>().sprite = plotSprites[counter];
        }
    }
Beispiel #3
0
    private void PythonPlotGenerator(GameObject equationObject, string fileName, string testImageName)
    {
        GameMath.Plot newCurve = new GameMath.Plot();

        GameMath.Expression newExpr = null;

        switch ((int)eqChoose.GetComponent <UpdateValue>().ReturnVariable())
        {
        case 0:
        {
            newExpr = new GameMath.LinearExpr();
            break;
        }

        case 1:
        {
            newExpr = new GameMath.QuadExpr();
            break;
        }

        case 2:
        {
            newExpr = new GameMath.CubeExpr();
            break;
        }

        case 3:
        {
            newExpr = new GameMath.AbsExpr();
            break;
        }

        case 4:
        {
            newExpr = new GameMath.SqrtExpr();
            break;
        }

        case 5:
        {
            newExpr = new GameMath.CbrtExpr();
            break;
        }

        case 6:
        {
            newExpr = new GameMath.RecipExpr();
            break;
        }

        default:
        {
            newExpr = new GameMath.LinearExpr();
            break;
        }
        }

        newExpr.AVertStretch.FloatData  = equationObject.GetComponent <UserEquationInput>().VarA;
        newExpr.BHorizStretch.FloatData = equationObject.GetComponent <UserEquationInput>().VarB;
        newExpr.CHorizShift.FloatData   = equationObject.GetComponent <UserEquationInput>().VarC;
        newExpr.DVertShift.FloatData    = equationObject.GetComponent <UserEquationInput>().VarD;

        newExpr.PyExpression();

        Debug.Log(newExpr.PlotString.StrData);

        //GameMath.AbsExpr newExpr = new GameMath.AbsExpr(equationObject.GetComponent<UserEquationInput>().VarA, equationObject.GetComponent<UserEquationInput>().VarB, equationObject.GetComponent<UserEquationInput>().VarC, equationObject.GetComponent<UserEquationInput>().VarD);

        //newCurve.Expr.StrData = "1*(1*x+0)**0.5+0";
        //newCurve.Expr.StrData = equationObject.GetComponent<UserEquationInput> ().CurrentPythonEq;
        newCurve.Expr.StrData = newExpr.PlotString.StrData;
        //Debug.Log(newExpr.PlotString.StrData);

        //newCurve.XStart.FloatData = 0f;

        GameMath.Axes newGraph = new GameMath.Axes();
        newGraph.AddCurve(newCurve);

        newGraph.ResourceFolder.StrData = "Plot Figures";
        //newGraph.FileName = "newGRAPH.png";
        newGraph.FileName.StrData = fileName;

        newGraph.GenerateGrid();
        newGraph.GeneratePlot(0);


        UnityEditor.AssetDatabase.Refresh();
        string rootF        = "Plot Figures/" + testImageName + "_AXES";
        Sprite myPlot_image = Resources.Load(rootF, typeof(Sprite)) as Sprite;

        Plot_Output_ref.GetComponent <Image> ().sprite = myPlot_image;

        string rootC         = "Plot Figures/" + testImageName + "_0";
        Sprite myCurve_image = Resources.Load(rootC, typeof(Sprite)) as Sprite;

        Curve_Output_ref.GetComponent <Image> ().sprite = myCurve_image;
    }
    private void PythonPlotGenerator(GameObject equationObject, string fileName, string testImageName)
    {
        GameMath.Plot newCurve = new GameMath.Plot ();

        GameMath.Expression newExpr = null;

        switch ((int)eqChoose.GetComponent<UpdateValue>().ReturnVariable())
        {
            case 0:
                {
                    newExpr = new GameMath.LinearExpr();
                    break;
                }
            case 1:
                {
                    newExpr = new GameMath.QuadExpr();
                    break;
                }
            case 2:
                {
                    newExpr = new GameMath.CubeExpr();
                    break;
                }
            case 3:
                {
                    newExpr = new GameMath.AbsExpr();
                    break;
                }
            case 4:
                {
                    newExpr = new GameMath.SqrtExpr();
                    break;
                }
            case 5:
                {
                    newExpr = new GameMath.CbrtExpr();
                    break;
                }
            case 6:
                {
                    newExpr = new GameMath.RecipExpr();
                    break;
                }
            default:
                {
                    newExpr = new GameMath.LinearExpr();
                    break;
                }
        }

        newExpr.AVertStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarA;
        newExpr.BHorizStretch.FloatData = equationObject.GetComponent<UserEquationInput>().VarB;
        newExpr.CHorizShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarC;
        newExpr.DVertShift.FloatData = equationObject.GetComponent<UserEquationInput>().VarD;

        newExpr.PyExpression();

        Debug.Log(newExpr.PlotString.StrData);

        //GameMath.AbsExpr newExpr = new GameMath.AbsExpr(equationObject.GetComponent<UserEquationInput>().VarA, equationObject.GetComponent<UserEquationInput>().VarB, equationObject.GetComponent<UserEquationInput>().VarC, equationObject.GetComponent<UserEquationInput>().VarD);

        //newCurve.Expr.StrData = "1*(1*x+0)**0.5+0";
        //newCurve.Expr.StrData = equationObject.GetComponent<UserEquationInput> ().CurrentPythonEq;
        newCurve.Expr.StrData = newExpr.PlotString.StrData;
        //Debug.Log(newExpr.PlotString.StrData);

        //newCurve.XStart.FloatData = 0f;

        GameMath.Axes newGraph = new GameMath.Axes();
        newGraph.AddCurve(newCurve);

        newGraph.ResourceFolder.StrData = "Plot Figures";
        //newGraph.FileName = "newGRAPH.png";
        newGraph.FileName.StrData = fileName;

        newGraph.GenerateGrid();
        newGraph.GeneratePlot(0);

        UnityEditor.AssetDatabase.Refresh();
        string rootF = "Plot Figures/" + testImageName+"_AXES";
        Sprite myPlot_image = Resources.Load(rootF, typeof(Sprite)) as Sprite;

        Plot_Output_ref.GetComponent<Image> ().sprite = myPlot_image;

        string rootC = "Plot Figures/" + testImageName+"_0";
        Sprite myCurve_image = Resources.Load(rootC, typeof(Sprite)) as Sprite;

        Curve_Output_ref.GetComponent<Image> ().sprite = myCurve_image;
    }