예제 #1
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
std::vector<scigraphics::number> scigraphics::markerLogarithmPositive::marks( const interval<number> Interval ) const
{
  if ( Interval.max() <= 0 )
    return marks( interval<number>(0.1,1) );
  if ( Interval.min() <= 0 )
    return marks( interval<number>( Interval.max()*1e-5, Interval.max() ) );
  return marksInPositiveInterval( Interval );
}
예제 #2
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
std::vector<scigraphics::number> scigraphics::markerLogarithmNegative::marks( const interval<number> Interval ) const
{
  std::vector<number> Result;
  if ( Interval.min() >= 0 )
    Result = marks( interval<number>(-1,-0.1) );
  else if ( Interval.max() >= 0 )
    Result = marks( interval<number>( Interval.min()*1e-5, Interval.min() ) );
  else
    Result = marksInPositiveInterval( interval<number>( -Interval.min(), -Interval.max() ) );

  for ( unsigned i = 0; i < Result.size(); i++ )
    Result[i] *= -1;

  return Result;
}
예제 #3
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
std::vector<scigraphics::number> scigraphics::markerLinear::marksWithStep( const interval<number> Interval, number Step ) const
{
  assert( Step > 0 );

  std::vector<scigraphics::number> Result;
  
  number MinValue = std::ceil( Interval.min() / Step - 1.0 ) * Step;
  number MaxValue = Interval.max() + 2*Step;
  number Epsilon  = epsilonForInterval(Interval);

  for ( unsigned i = 0; true; i++ )  
  {
    number Number = MinValue + i * Step;
    
    if ( Number > MaxValue )
      break;
    if ( i > 1024 )
      break;

    if ( -Epsilon < Number && Number < Epsilon )
      Number = 0;

    if ( inInterval(Number,Interval) )
       Result.push_back( Number );
  }

  return Result;
}
예제 #4
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
std::vector<scigraphics::number> scigraphics::markerLogarithm::marksInPositiveInterval( const interval<number> Interval ) const
{
  assert( Interval.min() > 0 );
  assert( Interval.max() > 0 );

  std::vector<number> Result;

  const number Steps[][10] =
  {
    { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 },
    { 1, 2, 5, 0 },
    { 1, 0 },
    { 1, 5, 0 },
    { 0 }
  };

  const number UnitStep[] = { 1, 0 };

  for ( unsigned i = 0; Steps[i][0] != 0; i++ )
  {
    Result = marksWithSteps( Interval, Steps[i], 10 );
    if ( vectorInMarkLimits(Result) )
      return Result;
  }

  for ( unsigned OrderStep = 100; OrderStep <= 100000; OrderStep *= 10 )
  {
    Result = marksWithSteps( Interval, UnitStep, OrderStep );
    if ( vectorInMarkLimits(Result) )
      return Result;
  }

  return Result;
}
예제 #5
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
std::vector<scigraphics::number> scigraphics::markerLogarithm::marksWithSteps( const interval<number> Interval, const number Steps[], number OrderStep ) const
{
  assert( Steps != NULL );
  assert( OrderStep > 1 );
  
  std::vector<scigraphics::number> Result;

  for ( number Order  = std::pow( 10, baseOrder( Interval.min() ) - 2.0 ); Order <= Interval.max(); Order *= OrderStep )
  {
    for ( unsigned i = 0; Steps[i] != 0; i++ )
    {
      number Number = Order * Steps[i];
      if ( inInterval(Number,Interval) )
        Result.push_back( Number );
    }
  }

  return Result;
}
예제 #6
0
파일: marker.cpp 프로젝트: zhgn/scigraphics
bool scigraphics::marker::inInterval( number Value, interval<number> Interval )
{
  number Epsilon = 3*epsilonForInterval(Interval);
  interval<number> ExtendedInterval( Interval.min() - Epsilon, Interval.max() + Epsilon );
  return ExtendedInterval.inInterval(Value);
}