IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 22, 2009, 2:54:39 PM (17 years ago)
Author:
eugene
Message:

other minor cleanups from eam_branches/20091113

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/grid.c

    r20936 r26258  
    11# include "data.h"
     2
     3int SetGridScales (double *major, double *minor, double range) {
     4
     5  double lrange, factor, mantis, fmantis, power;
     6
     7  lrange = log10(MAX(fabs(range), 1e-30));
     8  factor = (int) (lrange);
     9  if (lrange < 0) { factor -= 1; }
     10  mantis = lrange - factor;
     11  power = pow(10.0, factor);
     12  fmantis = pow(10.0, mantis);
     13  if ((fmantis >= 1.0) && (fmantis <=  2.0)) {
     14    *major = 0.5 * power;
     15    *minor = 0.1 * power;
     16  }
     17  if ((fmantis > 2.0) && (fmantis <=  4.0)) {
     18    *major = 1.0 * power;
     19    *minor = 0.2 * power;
     20  }
     21  if ((fmantis > 4.0) && (fmantis <=  6.0)) {
     22    *major = 1.0 * power;
     23    *minor = 0.5 * power;
     24  }
     25  if ((fmantis > 6.0) && (fmantis <=  10.0)) {
     26    *major = 2.0 * power;
     27    *minor = 0.5 * power;
     28  }
     29  return TRUE;
     30}
    231
    332int grid (int argc, char **argv) {
    433 
     34  double range, major, minor, first, next;
    535  int j, kapa, N, MinorTick, MajorTick;
    636  Vector Xvec, Yvec;
    7   double range, lrange, factor, mantis, fmantis, power, major, minor, first, next;
    837  Graphdata graphmode;
    938
     
    2857  major = minor = 1;
    2958  range = graphmode.xmax - graphmode.xmin;
    30   lrange = log10(MAX(fabs(range), 1e-30));
    31   factor = (int) (lrange);
    32   if (lrange < 0) { factor -= 1; }
    33   mantis = lrange - factor;
    34   power = pow(10.0, factor);
    35   fmantis = pow(10.0, mantis);
    36   if ((fmantis >= 1.0) && (fmantis <=  2.0)) {
    37     major = 0.5 * power;
    38     minor = 0.1 * power;
    39   }
    40   if ((fmantis > 2.0) && (fmantis <=  4.0)) {
    41     major = 1.0 * power;
    42     minor = 0.2 * power;
    43   }
    44   if ((fmantis > 4.0) && (fmantis <=  6.0)) {
    45     major = 1.0 * power;
    46     minor = 0.5 * power;
    47   }
    48   if ((fmantis > 6.0) && (fmantis <=  10.0)) {
    49     major = 2.0 * power;
    50     minor = 0.5 * power;
    51   }
     59  SetGridScales (&major, &minor, range);
    5260  if (graphmode.xmin > 0)
    5361    first = minor + minor*((int)(graphmode.xmin/minor));
     
    108116
    109117  range = graphmode.ymax - graphmode.ymin;
    110   lrange = log10(MAX(fabs(range), 1e-30));
    111   factor = (int) (lrange);
    112   if (lrange < 0) { factor -= 1; }
    113   mantis = lrange - factor;
    114   power = pow(10.0, factor);
    115   fmantis = pow(10.0, mantis);
    116   if ((fmantis >= 1.0) && (fmantis <=  2.0)) {
    117     major = 0.5 * power;
    118     minor = 0.1 * power;
    119   }
    120   if ((fmantis > 2.0) && (fmantis <=  4.0)) {
    121     major = 1.0 * power;
    122     minor = 0.2 * power;
    123   }
    124   if ((fmantis > 4.0) && (fmantis <=  6.0)) {
    125     major = 1.0 * power;
    126     minor = 0.5 * power;
    127   }
    128   if ((fmantis > 6.0) && (fmantis <=  10.0)) {
    129     major = 2.0 * power;
    130     minor = 0.5 * power;
    131   }
     118  SetGridScales (&major, &minor, range);
    132119  if (graphmode.ymin > 0)
    133120    first = minor + minor*((int)(graphmode.ymin/minor));
Note: See TracChangeset for help on using the changeset viewer.