private void Update()
    {
        float         t = Time.time;
        GraphFunction f = functions[(int)function];

        /*
         * for (int i = 0; i < points.Length; i++) {
         *  Vector3 position = points[i].localPosition;
         *
         *  //position.y = SinFunction(position.x, t);
         *  position= f(position.x, position.z, t);
         *
         *  points[i].localPosition = position;
         * }
         */
        float step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #2
0
    void Update()
    {
        if (changed)
        {
            DestroyChilds();
            CreatePoints();
            changed = false;
        }

        float t = Time.time;

        amplitud = (amplitud + t) % 20.0f;

        GraphFunction f = functions[(int)function];

        float step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; ++z)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; ++x, ++i)
            {
                float u = (x + 0.5f) * step - 1f;

                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #3
0
    private void Update()
    {
        float         t = Time.time;
        GraphFunction f = functions[(int)function];

        float step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }

        /*
         * for (int i = 0; i < points.Length; i++)
         * {
         *  Transform point = points[i];
         *  Vector3 position = point.localPosition;
         *  position.y = f(position.x, position.z, t);
         *
         *  if (positiveOnly)
         *  {
         *      if (position.y < 0)
         *          position.y = 0;
         *  }
         *  point.localPosition = position;
         * }
         */
    }
Пример #4
0
    private void Update()
    {
        float         t = Time.time;
        GraphFunction f = functions[(int)function];

        //for (int i = 0; i < points.Length; i++)
        //{
        //    Transform point = points[i];
        //    Vector3 position = point.localPosition;

        //    position.y = f(position.x, position.z, t);

        //    point.localPosition = position;
        //}

        float step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        float           t   = Time.time;
        GraphFunction   f   = functions[(int)function];
        Graph3DFunction f3d = functions3D[(int)function3D];

        if (is3D)
        {
            float step = 2f / resolution;
            for (int i = 0, z = 0; z < resolution; z++)
            {
                float v = (z + 0.5f) * step - 1f;
                for (int x = 0; x < resolution; x++, i++)
                {
                    float u = (x + 0.5f) * step - 1f;
                    points[i].localPosition = f3d(u, v, t);
                }
            }
        }
        else
        {
            for (int i = 0; i < points.Length; i++)
            {
                Transform point    = points[i];
                Vector3   position = point.localPosition;
                position.y          = f(position.x, position.z, t);
                point.localPosition = position;
            }
        }
    }
    void Update()                                   // only the y changing
    {
        float t = Time.time;                        // Variable t refers to time

        GraphFunction f = functions[(int)function]; // Method delegation part using the array of functions defined above

        //if (function == 0)
        //{
        //    f = SineFunction;
        //} else
        //{
        //    f = MultiSineFunction;
        //}

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];           // reference to the current array element. then put assign it as point
            Vector3   position = point.localPosition; // get the position of point and put it as position
            // position.y = Mathf.Sin(Mathf.PI * (position.x + Time.time * 0.5f)); // derive the y position -> y is a sin function with x as variable
            //                                                                     // time pi to be in scaleto be in between -1 and 1
            //                                                                    // added the time variable to have, f(x,t) = sin(pi(x + t))
            //if (function == 0)
            //{
            //    position.y = SineFunction(position.x, t);

            //}
            //else
            //{
            //    position.y = MultiSinFunction(position.x, t);

            //} // Not using this anymore, we delegate the methods
            position.y          = f(position.x, position.z, t);
            point.localPosition = position; // need to assign back position to the point because we changed only the local variale not the object
        }
    }
Пример #7
0
    void Update()
    {
        float         time = Time.time;
        GraphFunction f    = functions[(int)activeFunction];

        for (int i = 0; i < points.Length; ++i)
        {
            Transform point    = points[i].point;
            Vector3   position = point.localPosition;
            if (activeFunction == 0)
            {
                point.localPosition = f(position, resolution, points[i].time, c1, c2, i);
                if (points[i].time > 10)
                {
                    points[i].time = 0;
                }
            }
            else if ((int)activeFunction == 1 || (int)activeFunction == 2)
            {
                point.localPosition = f(position, resolution, points[i].time, c1, c2, i);
            }
            else
            {
                point.localPosition = f(position, resolution, time, c1, c2, i);
            }
            points[i].point = point;
            points[i].time += 0.02f;
        }
    }
Пример #8
0
 public GraphType(string Name, string axisX, string axisY, GT DualGraph, GraphFunction PlotFunc)
 {
     this.Name = Name;
     this.axisX = axisX;
     this.axisY = axisY;
     this._DualGraph = DualGraph;
     this.PlotFunc = PlotFunc;
 }
Пример #9
0
 public GraphType(string Name, string axisX, string axisY, GT DualGraph, GraphFunction PlotFunc)
 {
     this.Name       = Name;
     this.axisX      = axisX;
     this.axisY      = axisY;
     this._DualGraph = DualGraph;
     this.PlotFunc   = PlotFunc;
 }
Пример #10
0
    private async void Update()
    {
        float         time = Time.time;
        GraphFunction f    = functions[(int)functionType];

        float step = 2f / resolution;

        await LoopAsync(resolution, step, f, time);
    }
Пример #11
0
    private void Update()
    {
        GraphFunction func = functions[function];

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;
            // position.y=position.x*(position.x+Time.time);
            position.y          = func(position.x, position.z, Time.time);
            point.localPosition = position;
        }
    }
Пример #12
0
    // Update is called once per frame
    void Update()
    {
        float         t = Time.time;
        GraphFunction f = functions[(int)function];

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;
            position.y          = amplitude * f(position.x, position.z, t) + yOffset;
            point.localPosition = position;
        }
    }
Пример #13
0
        // Update is called once per frame
        void Update()
        {
            // Update the y position of each point every frame w.r.t. time
            float         time = Time.time;
            GraphFunction func = Functions[(int)Function];

            for (int i = 0; i < Points.Length; i++)
            {
                Transform currentPoint = Points[i];
                Vector3   position     = currentPoint.localPosition;
                position.y = func(position.x, position.z, time);
                currentPoint.localPosition = position;
            }
        }
Пример #14
0
    void Update()
    {
        GraphFunction func = PseudoChaoticWave;

        for (int i = 0; i < numPoints; i++)
        {
            Transform point = points[i];
            point.localPosition = new Vector3(
                point.localPosition.x,
                func(point.localPosition.x + Time.time),
                point.localPosition.z
                );
        }
    }
    // Update is called once per frame
    void Update()
    {
        GraphFunction foo = functions[(int)function];

        float t = Time.time;

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;
            position.y          = foo(position.x, position.z, Time.time);
            point.localPosition = position;
        }
    }
Пример #16
0
    private void Update()
    {
        float         time = Time.time;
        GraphFunction f    = functions[(int)functionNames];

        for (int i = 0; i < points.Length; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;
            position.y = f(position.x, time);
            //  Debug.LogFormat("X: " + position.x.ToString());
            // Debug.LogFormat("Y: " + position.y.ToString());
            point.localPosition = position;
        }
    }
Пример #17
0
    void Update()
    {
        float         t = Time.time;
        GraphFunction f = functions[(int)function];

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #18
0
    // Update is called once per frame
    void Update()
    {
        float         t = Time.time;
        GraphFunction f = _graphFunctions[(int)functionSelector];

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * _step - 4f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * _step - 4f;
                _segments[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #19
0
 private void Start()
 {
     GraphFuncs = new GraphFunction[]
     {
         Sine,
         Sine2D,
         MultiSine,
         MultiSine2D,
         Ripple,
         Cylinder,
         Sphere,
         Torus
     };
     MyFunction = GraphFuncs[(int)selectedFunction];
 }
Пример #20
0
    void Update()
    {
        GraphFunction f    = functions[(int)function];
        float         t    = Time.time;//Getting the value of time from Time Class.
        float         step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #21
0
    private void Update()
    {
        float         t    = Time.time;
        GraphFunction f    = m_functions[(int)m_function];
        float         step = 2f / m_resolution;

        for (int i = 0, z = 0; z < m_resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < m_resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                m_points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #22
0
    private void Update()
    {
        GraphFunction fn   = functions[(int)selectedFunction];
        float         t    = Time.time;
        float         step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = fn(u, v, t);
            }
        }
    }
    private void UpdateFunction()
    {
        float         t    = Time.time;
        GraphFunction f    = functions[(int)graphName];
        float         step = 2f / _resolution;

        for (int i = 0, z = 0; z < _resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < _resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                _points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #24
0
    public async Task LoopAsync(int resolution, float step, GraphFunction f, float time)
    {
        List <Task> listOfTasks = new List <Task>();

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                listOfTasks.Add(DoAsync(i, f, u, v, time));
            }
        }

        await Task.WhenAll(listOfTasks);
    }
Пример #25
0
    private void Update()
    {
        var           t    = Time.time;
        GraphFunction f    = Functions[(int)function];
        var           step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            var v = (z + 0.5f) * step - 1f;
            for (var x = 0; x < resolution; x++, i++)
            {
                var u = (x + 0.5f) * step - 1f;
                _points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #26
0
    void UpdateGraph()
    {
        float         time          = Time.time;
        GraphFunction functionToRun = functions[(int)function];
        float         step          = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float u = (x + 0.5f) * step - 1f;
                points[i].localPosition = functionToRun(u, v, time);
            }
        }
    }
Пример #27
0
    void Update()
    {
        float         t    = Time.time;
        float         step = 2f / resolution;
        GraphFunction f    = functions[(int)function];

        for (int i = 0, x = 0; x < resolution; x++)
        {
            float u = (-1.0f + (x + 0.5f) * step);
            for (int z = 0; z < resolution; z++, i++)
            {
                float v = (-1.0f + (z + 0.5f) * step);
                points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #28
0
    private void Update()
    {
        // updates graph point per frame
        float         time          = Time.time;
        GraphFunction graphFunction = functions[(int)functionName]; // uses the above created delegate array
        float         graphStep     = 2f / graphResolution;

        for (int i = 0, z = 0; z < graphResolution; z++)
        {
            float v = (z + 0.5f) * graphStep - 1f;
            for (int x = 0; x < graphResolution; x++, i++)
            {
                float u = (x + 0.5f) * graphStep - 1f;
                graphPoints[i].localPosition = graphFunction(u, v, time);
            }
        }
    }
Пример #29
0
    private void Update()
    {
        float         t = Time.time;
        GraphFunction f = Functions[(int)Function];

        float Step = 2f / Resolution;

        for (int i = 0, z = 0; z < Resolution; z++)
        {
            float v = (z + 0.5f) * Step - 1f;
            for (int x = 0; x < Resolution; x++, i++)
            {
                float u = (x + 0.5f) * Step - 1f;
                Points[i].localPosition = f(u, v, t);
            }
        }
    }
Пример #30
0
    //Calls every frame
    void Update()
    {
        //Time elapsed
        float t = Time.time;

        //Choosing the right function
        GraphFunction f = functions[(int)function];

        for (int i = 0; i < resolution * resolution; i++)
        {
            Transform point    = points[i];
            Vector3   position = point.localPosition;

            position.y          = f(position.x, position.z, t);
            point.localPosition = position;
        }
    }
Пример #31
0
    /*void Build() {
     *  float step = 2f / resolution;
     *  Vector3 scale = Vector3.one * step;
     *  Vector3 position;
     *  position.y = 0f;
     *  position.z = 0f;
     *  points = new Transform[resolution * resolution];
     *  for (int i = 0; i < points.Length; i++) {
     *      Transform point = Instantiate(pointPrefab);
     *      point.localScale = scale;
     *      point.SetParent(transform, false);
     *      points[i] = point;
     *  }
     * }*/

    public void UpdateGraph()
    {
        float         t    = Time.time;
        GraphFunction f    = functions[(int)function];
        float         step = 2f / resolution;

        for (int i = 0, z = 0; z < resolution; z++)
        {
            float v = (z + 0.5f) * step - 1f;
            for (int x = 0; x < resolution; x++, i++)
            {
                float   u          = (x + 0.5f) * step - 1f;
                Vector3 tempVector = f(u, v, t);
                points[i].localPosition = new Vector3(points[i].localPosition.x, tempVector.y, points[i].localPosition.z);
            }
        }
    }