- rot90() and rot270() added to xy.h
authoralpar
Mon, 07 Mar 2005 07:53:20 +0000
changeset 1202da44ee225dad
parent 1201 cb26a6250401
child 1203 14f951664a63
- rot90() and rot270() added to xy.h
- graph_to_eps.h's own rot() func. replaced to this
src/lemon/graph_to_eps.h
src/lemon/xy.h
     1.1 --- a/src/lemon/graph_to_eps.h	Sun Mar 06 21:20:49 2005 +0000
     1.2 +++ b/src/lemon/graph_to_eps.h	Mon Mar 07 07:53:20 2005 +0000
     1.3 @@ -157,7 +157,6 @@
     1.4  ///Returns black for light colors and white for the dark ones.
     1.5  ///\todo weighted average would be better
     1.6  inline Color distantBW(const Color &c){
     1.7 -  //  double v=(c.getR()+c.getG()+c.getB())<1.5?1:0;
     1.8    double v=(.2125*c.getR()+.7154*c.getG()+.0721*c.getB())<.5?1:0;
     1.9    return Color(v,v,v);
    1.10  }
    1.11 @@ -327,10 +326,6 @@
    1.12      return (g.source(e)==g.source(f)&&g.target(e)==g.target(f))||
    1.13        (g.source(e)==g.target(f)&&g.target(e)==g.source(f));
    1.14    }
    1.15 -  static xy<double> rot(xy<double> v) 
    1.16 -  {
    1.17 -    return xy<double>(v.y,-v.x);
    1.18 -  }
    1.19    template<class TT>
    1.20    static std::string psOut(const xy<TT> &p) 
    1.21      {
    1.22 @@ -775,7 +770,7 @@
    1.23  
    1.24  	  for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
    1.25  	    sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
    1.26 -	    xy<double> mm=m+rot(d)*sw/.75;
    1.27 +	    xy<double> mm=m+rot90(d)*sw/.75;
    1.28  	    if(_drawArrows) {
    1.29  	      int node_shape;
    1.30  	      xy<double> s=_coords[g.source(*e)];
    1.31 @@ -811,7 +806,7 @@
    1.32  		 << bez.p2.x << ' ' << bez.p2.y << ' '
    1.33  		 << bez.p3.x << ' ' << bez.p3.y << ' '
    1.34  		 << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
    1.35 -	      xy<double> dd(rot(linend-apoint));
    1.36 +	      xy<double> dd(rot90(linend-apoint));
    1.37  	      dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
    1.38  		sqrt(dd.normSquare());
    1.39  	      os << "newpath " << psOut(apoint) << " moveto "
     2.1 --- a/src/lemon/xy.h	Sun Mar 06 21:20:49 2005 +0000
     2.2 +++ b/src/lemon/xy.h	Mon Mar 07 07:53:20 2005 +0000
     2.3 @@ -180,6 +180,29 @@
     2.4      return os;
     2.5    }
     2.6  
     2.7 +  ///Rotate by 90 degrees
     2.8 +
     2.9 +  ///Returns its parameter rotated by 90 degrees in positive direction.
    2.10 +  ///\relates xy
    2.11 +  ///
    2.12 +  template<typename T>
    2.13 +  inline xy<T> rot90(const xy<T> &z)
    2.14 +  {
    2.15 +    return xy<T>(-z.y,z.x);
    2.16 +  }
    2.17 +
    2.18 +  ///Rotate by 270 degrees
    2.19 +
    2.20 +  ///Returns its parameter rotated by 90 degrees in negative direction.
    2.21 +  ///\relates xy
    2.22 +  ///
    2.23 +  template<typename T>
    2.24 +  inline xy<T> rot270(const xy<T> &z)
    2.25 +  {
    2.26 +    return xy<T>(z.y,-z.x);
    2.27 +  }
    2.28 +
    2.29 +  
    2.30  
    2.31    /// A class to calculate or store the bounding box of plainvectors.
    2.32