FromFuncResult() public method

public FromFuncResult ( double result, double min, double max ) : int
result double
min double
max double
return int
Ejemplo n.º 1
0
        public override int DrawBatch(int maxBlocksToDraw)
        {
            int    count = 0;
            double fromT, toT, stepT;
            double fromU, toU, stepU;
            double fromV, toV, stepV;

            GetIterationBounds(0, out fromT, out toT, out stepT);
            GetIterationBounds(1, out fromU, out toU, out stepU);
            GetIterationBounds(2, out fromV, out toV, out stepV);

            for (double t = fromT; t <= toT; t += stepT)
            {
                for (double u = fromU; u <= toU; u += stepU)
                {
                    for (double v = fromV; v <= toV; v += stepV)
                    {
                        Coords.X = _scaler.FromFuncResult(_expressions[0].Evaluate(t, u, v), Bounds.XMin, Bounds.XMax);
                        Coords.Y = _scaler.FromFuncResult(_expressions[1].Evaluate(t, u, v), Bounds.YMin, Bounds.YMax);
                        Coords.Z = _scaler.FromFuncResult(_expressions[2].Evaluate(t, u, v), Bounds.ZMin, Bounds.ZMax);
                        if (DrawOneBlock())
                        {
                            ++count;
                        }
                        //if (TimeToEndBatch)
                        //    return count;
                    }
                }
            }
            IsDone = true;
            return(count);
        }
Ejemplo n.º 2
0
        //this method exists to box coords nicely as ref params
        private int InternalDraw(ref int arg1, ref int arg2, ref int val, int min1, int max1, int min2, int max2,
                                 int minV, int maxV, int maxBlocksToDraw)
        {
            _count = 0;
            int exCount = 0;

            DrawFasePrepare(min1, max1, min2, max2);

            for (arg1 = min1; arg1 <= max1 && MathCommands.MaxCalculationExceptions >= exCount; ++arg1)
            {
                for (arg2 = min2; arg2 <= max2; ++arg2)
                {
                    try
                    {
                        int fval =
                            _scaler.FromFuncResult(
                                _expression.Evaluate(_scaler.ToFuncParam(arg1, min1, max1),
                                                     _scaler.ToFuncParam(arg2, min2, max2)),
                                minV, maxV);
                        DrawFase1(fval, ref arg1, ref arg2, ref val, min1, max1, min2, max2, minV, maxV, maxBlocksToDraw);
                        //if (TimeToEndBatch)
                        //    return _count;
                    }
                    catch (Exception)
                    {
                        //the exception here is kinda of normal, for functions (especially interesting ones)
                        //may have eg punctured points; we just have to keep an eye on the number, since producing 10000
                        //exceptions in the multiclient application is not the best idea
                        if (++exCount > MathCommands.MaxCalculationExceptions)
                        {
                            Player.Message("Function drawing is interrupted: too many (>" +
                                           MathCommands.MaxCalculationExceptions + ") calculation exceptions.");
                            break;
                        }
                    }
                }
            }
            //the real drawing for the surface variant
            DrawFase2(ref arg1, ref arg2, ref val, min1, max1, min2, max2, minV, maxV, maxBlocksToDraw);
            return(_count);
        }