fCraft.Scaler.FromFuncResult C# (CSharp) Method

FromFuncResult() public method

public FromFuncResult ( double result, double min, double max ) : int
result double
min double
max double
return int
        public int FromFuncResult( double result, double min, double max )
        {
            switch ( _scaling ) {
                case Scaling.ZeroToMaxBound:
                    return ( int )( result + min );
                case Scaling.Normalized:
                    return ( int )( result * Math.Max( 1, max - min ) + min );
                case Scaling.DoubleNormalized:
                    return ( int )( ( result + 1 ) * Math.Max( 1, max - min ) / 2.0 + min );
                default:
                    throw new Exception( "unknown scaling" );
            }
        }

Usage Example

Example #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);
        }
All Usage Examples Of fCraft.Scaler::FromFuncResult