iTween.PathControlPointGenerator C# (CSharp) Method

PathControlPointGenerator() private static method

private static PathControlPointGenerator ( Vector3 path ) : Vector3[]
path Vector3
return Vector3[]
    private static Vector3[] PathControlPointGenerator(Vector3[] path)
    {
        Vector3[] suppliedPath;
        Vector3[] vector3s;

        //create and store path points:
        suppliedPath = path;

        //populate calculate path;
        int offset = 2;
        vector3s = new Vector3[suppliedPath.Length+offset];
        Array.Copy(suppliedPath,0,vector3s,1,suppliedPath.Length);

        //populate start and end control points:
        //vector3s[0] = vector3s[1] - vector3s[2];
        vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]);
        vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]);

        //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline!
        if(vector3s[1] == vector3s[vector3s.Length-2]){
            Vector3[] tmpLoopSpline = new Vector3[vector3s.Length];
            Array.Copy(vector3s,tmpLoopSpline,vector3s.Length);
            tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3];
            tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2];
            vector3s=new Vector3[tmpLoopSpline.Length];
            Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length);
        }

        return(vector3s);
    }
iTween