Example #1
0
        static void Main(string[] args)
        {
            float a, b, c, x;

            Console.Write("Введите значение a для линейной функции: ");
            a = Convert.ToSingle(Console.ReadLine());
            Console.Write("Введите значение b для линейной функции: ");
            b = Convert.ToSingle(Console.ReadLine());
            Console.Write("Введите значение x для линейной функции: ");
            x = Convert.ToSingle(Console.ReadLine());
            LineFunction line = new LineFunction(a, b, x);
            float        f_x  = line.Calculate();

            Console.WriteLine($"f(x) = {a}*{x} + {b} = {f_x}");

            Console.Write("Введите значение a для квадратичной функции: ");
            a = Convert.ToSingle(Console.ReadLine());
            Console.Write("Введите значение b для квадратичной функции: ");
            b = Convert.ToSingle(Console.ReadLine());
            Console.Write("Введите значение x для квадратичной функции: ");
            c = Convert.ToSingle(Console.ReadLine());
            Console.Write("Введите значение x для квадратичной функции: ");
            x = Convert.ToSingle(Console.ReadLine());
            QuadrationFunction quadration = new QuadrationFunction(a, b, c, x);

            f_x = quadration.Calculate();
            Console.WriteLine($"f(x) = {a}*{x}*{x} + {b}*{x} + {c} = {f_x}");


            Console.ReadKey();
        }
Example #2
0
 public TradeWindGenerator(int xSize, int ySize)
 {
     this.xSize = xSize;
     this.ySize = ySize;
     hadleyLow  = new LineFunction(0, 4, midLatitude / 2f, 7);
     hadleyHigh = new LineFunction(midLatitude / 2f, 7, midLatitude, 5);
     mid        = new LineFunction(midLatitude, 5, polarLatitude, 10);
     polar      = new LineFunction(polarLatitude, 10, 90, 6);
     wm         = new Map <Vector2>(xSize, ySize);
 }
    public TemperatureMap(TerrainMap tm, int month)
    {
        this.xSize      = tm.xSize;
        this.ySize      = tm.ySize;
        this.grid       = new float[xSize, ySize];
        this.terrainmap = tm;
        float st, lt, lat;

        for (int y = 0; y < ySize; y++)
        {
            lat = Latitude.getLatitude(y, ySize);
            st  = getSeaTemperature(lat, month);
            lt  = getLandTemperature(lat, month);
            for (int x = 0; x < xSize; x++)
            {
                if (tm.grid [x, y].terrainType == TerrainType.sea)
                {
                    this.grid [x, y] = st;
                }
                else
                {
                    this.grid [x, y] = lt;
                }
            }
        }
        smoothMean(5, 5);
        smoothMean(1, 10);
        IFunction altitudeTemperature = new LineFunction(-80, 40);
        IFunction depthTemperature    = new LineFunction(10, -5);

        for (int x = 0; x < xSize; x++)
        {
            for (int y = 0; y < ySize; y++)
            {
                if (tm.grid [x, y].terrainType != TerrainType.sea)
                {
                    this.grid [x, y] += altitudeTemperature.calculate(tm.grid [x, y].height);
                }
                else
                {
                    this.grid [x, y] += depthTemperature.calculate(tm.grid [x, y].height);
                }
            }
        }
    }
    private Map <Vector2> blendLayers()
    {
        Map <Vector2> m       = new Map <Vector2>(xSize, ySize);
        IFunction     redistr = new LineFunction(0, 3, 60, 1.5f);
        Vector2       v;
        float         mag;

        for (int x = 0; x < xSize; x++)
        {
            for (int y = 0; y < ySize; y++)
            {
                v   = LayersWeightedAverage(x, y);
                mag = v.magnitude;
                v.Normalize();
                v *= mag + redistr.calculate(mag);
                m.setAt(x, y, v);
            }
        }
        return(m);
    }