NPlot.LogAxis.DetermineTickSpacing C# (CSharp) Method

DetermineTickSpacing() private method

Determines the tick spacing.
private DetermineTickSpacing ( ) : double
return double
        private double DetermineTickSpacing( )
        {
            if ( double.IsNaN(WorldMin) || double.IsNaN(WorldMax) )
            {
                throw new NPlotException( "world extent of axis is not set." );
            }

            // if largeTickStep has been set, it is used
            if ( !double.IsNaN( this.largeTickStep_) )
            {
                if ( this.largeTickStep_ <= 0.0f )
                {
                    throw new NPlotException( "can't have negative tick step - reverse WorldMin WorldMax instead." );
                }

                return this.largeTickStep_;
            }

            double MagRange = (double)(Math.Floor(Math.Log10(WorldMax)) - Math.Floor(Math.Log10(WorldMin))+1.0);

            if ( MagRange > 0.0 )
            {
                // for now, a simple logic
                // start with a major tick every order of magnitude, and
                // increment if in order not to have more than 10 ticks in
                // the plot.
                double roundTickDist=1.0F;
                int nticks=(int)(MagRange/roundTickDist);
                while (nticks > 10)
                {
                    roundTickDist++;
                    nticks=(int)(MagRange/roundTickDist);
                }
                return roundTickDist;
            }
            else
            {
                return 0.0f;
            }
        }