Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Attributes
polar_rep Struct Reference
Inheritance diagram for polar_rep:
Inheritance graph
[legend]
Collaboration diagram for polar_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 polar_rep (array< SI > subd, array< string > col, point o, double st, SI ast)
 operator tree ()
array< grid_curveget_curves (point lim1, point lim2, bool b)
point find_closest_point (point p, point pmin, point pmax)
virtual void set_aspect (tree aspect)
virtual array< grid_curveget_curves_around (point p, double delta, frame f)
virtual point find_point_around (point p, double delta, frame f)

Public Attributes

double step
SI astep
int ref_count

Protected Attributes

array< SIsubd
array< stringcol
point center

Detailed Description

Definition at line 255 of file grid.cpp.


Constructor & Destructor Documentation

polar_rep::polar_rep ( array< SI subd,
array< string col,
point  o,
double  st,
SI  ast 
) [inline]

Definition at line 258 of file grid.cpp.

                                                                           :
    grid_rep (subd, col, o), step (st), astep (ast) {}

Member Function Documentation

point polar_rep::find_closest_point ( point  p,
point  pmin,
point  pmax 
) [virtual]

Implements grid_rep.

Definition at line 337 of file grid.cpp.

                                                              {
  double n, a, oldn= 0, olda= 0, ssubd;
  point res= p;
  p= p-center;
  int i;
  for (i=1; i<N(subd); i++) {
    ssubd= (double)subd[i];
    if (ssubd==0) continue;
    n= nearest (norm(p)*(ssubd/step));
    if (fnull (norm (p), 1.0e-6))
      a= 0.0;
    else
      a= nearest ((arg(p)/(2*tm_PI))*astep*ssubd);
    n= n*(step/ssubd);
    a= a/(astep*ssubd);
    if (i!=1) {
      res= center + oldn * point (cos(2*tm_PI*a), sin(2*tm_PI*a));
      if (inside_rectangle (res, pmin, pmax))
        return res;
      res= center + n * point (cos(2*tm_PI*olda), sin(2*tm_PI*olda));
      if (inside_rectangle (res, pmin, pmax))
        return res;
    }
    oldn= n;
    olda= a;
    res= center + n * point (cos(2*tm_PI*a), sin(2*tm_PI*a));
    if (inside_rectangle (res, pmin, pmax))
      return res;
  }
  return res;
}

Here is the call graph for this function:

point grid_rep::find_point_around ( point  p,
double  delta,
frame  f 
) [virtual, inherited]

Definition at line 76 of file grid.cpp.

                                                           {
  point p2= f (p);
  point pmin, pmax;
  pmin= f[point (p2[0]-delta, p2[1]-delta)];
  pmax= f[point (p2[0]+delta, p2[1]+delta)];
  return find_closest_point (p, pmin, pmax);
}

Here is the call graph for this function:

array< grid_curve > polar_rep::get_curves ( point  lim1,
point  lim2,
bool  b 
) [virtual]

Implements grid_rep.

Definition at line 279 of file grid.cpp.

                                                     {
  (void) b;
  array<grid_curve> res;
  if (N(subd)<1) return res;
  double x1= min (lim1[0], lim2[0]);
  double y1= min (lim1[1], lim2[1]);
  double x2= max (lim1[0], lim2[0]);
  double y2= max (lim1[1], lim2[1]);
  double xo= center[0];
  double yo= center[1];
  point P1, P2;
  if (x1<=0 && y1<=0 && x2>=0 && y2>=0) {
    P1= point (0, 0);
    P2= point (x2, y2) - point (x1, y1);
  }
  else {
    double ox= (x1 + x2) / 2;
    double oy= (y1 + y2) / 2;
    if (oy>=0)
      P1= point (0, y1>=0 ? y1 : 0);
    else
      P1= point (0, y2<=0 ? y2 : 0);

    if (ox>=0 && oy>=0)
      P2= point (x2, y2);
    else
    if (ox<=0 && oy>=0)
      P2= point (x1, y2);
    else
    if (ox<=0 && oy<=0)
      P2= point (x1, y1);
    else
    if (ox>=0 && oy<=0)
      P2= point (x2, y1);
  }
  double r, R1= norm (P1), R2= norm (P2);
  int i;
  for (i= N(subd)-1; i>=1; i--) {
    SI nsub;
    nsub= subd[i];
    if (nsub!=0) {
      SI j;
      double s= max (step/nsub, 1.0e-6);
      for (r=0; r<=R2; r+=s)
       if (r>=R1)
         res << create_arc (xo+r, yo, xo, yo+r, xo-r, yo, col[i]);
      for (j=0; j<astep*nsub; j++)
        res << create_line (xo, yo, xo+R2*cos((2*tm_PI*j)/(astep*nsub)),
                                    yo+R2*sin((2*tm_PI*j)/(astep*nsub)),
                                    col[i]);
    }
  }
  res << create_line (x1, yo, x2, yo, col[0]);
  res << create_line (xo, y1, xo, y2, col[0]);
  return res;
}

Here is the call graph for this function:

array< grid_curve > grid_rep::get_curves_around ( point  p,
double  delta,
frame  f 
) [virtual, inherited]

Reimplemented in cartesian_rep.

Definition at line 67 of file grid.cpp.

                                                           {
  point p2= f (p);
  point pmin, pmax;
  pmin= f[point (p2[0]-delta, p2[1]-delta)];
  pmax= f[point (p2[0]+delta, p2[1]+delta)];
  return get_curves (pmin, pmax, true);
}

Here is the call graph for this function:

polar_rep::operator tree ( ) [inline, virtual]

Implements grid_rep.

Definition at line 260 of file grid.cpp.

{ return "polar"; }
void grid_rep::set_aspect ( tree  aspect) [virtual, inherited]

Definition at line 21 of file grid.cpp.

                                 {
  subd= array<SI> (2);
  subd[0]= 0;
  subd[1]= 1;
  col= array<string> (2);
  col[0]= "#808080";
  col[1]= "#c0c0c0";
  if (is_tuple (aspect)) {
    int i;
    bool b= false;
    subd= array<SI> (N(aspect));
    col= array<string> (N(aspect));
    for (i=0; i<N(aspect); i++) {
       if (is_tuple (aspect[i], "axes", 1)) {
         subd[i]= 0;
         b= true;
       }
       else {
         subd[i]= as_int (aspect[i][0]);
       }
       col[i]= as_string (aspect[i][1]);
    }
    if (!b) {
      array<SI> subd0 (1);
      array<string> col0 (1);
      subd0[0]= 0;
      col0[0]= "#e0e0ff";
      subd= subd0 << subd;
      col= col0 << col;
    }
    do {
      b= true;
      for (i=1; i<N(subd); i++)
         if (subd[i-1]>subd[i]) {
           SI j;
           string c;
           j= subd[i-1];subd[i-1]= subd[i];subd[i]= j;
           c= col[i-1];col[i-1]= col[i];col[i]= c;
           b= false;
         }
    }
    while (!b);
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 257 of file grid.cpp.

point grid_rep::center [protected, inherited]

Definition at line 38 of file grid.hpp.

array<string> grid_rep::col [protected, inherited]

Definition at line 37 of file grid.hpp.

int abstract_struct::ref_count [inherited]

Definition at line 142 of file basic.hpp.

Definition at line 256 of file grid.cpp.

array<SI> grid_rep::subd [protected, inherited]

Definition at line 36 of file grid.hpp.


The documentation for this struct was generated from the following file: