Ejemplo n.º 1
0
    public VectorFieldStruct(Vector3 dimension, int resolution, System.Func <Vector3, Vector3> fieldFunction)
    {
        this.dimension = dimension;
        field          = new Native3DArray <Vector3>(resolution, resolution, resolution);
        for (int i = 0; i < field.GetLength(0); i++)
        {
            for (int j = 0; j < field.GetLength(1); j++)
            {
                for (int k = 0; k < field.GetLength(2); k++)
                {
                    Vector3 coordinate = new Vector3(
                        dimension.x * (i / ((float)field.GetLength(0) - 1)),
                        dimension.y * (j / ((float)field.GetLength(1) - 1)),
                        dimension.z * (k / ((float)field.GetLength(2) - 1)));

                    field.Set(i, j, k, fieldFunction(coordinate));
                }
            }
        }
    }