home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / src / plane / _misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  1.3 KB  |  65 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  _misc.c
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. #include <LEDA/plane.h>
  17. #include <math.h>
  18.  
  19. static const double eps = 1e-10;
  20.  
  21.  
  22. //------------------------------------------------------------------------------
  23. // some usefull functions
  24. // (should be friends)
  25. //------------------------------------------------------------------------------
  26.  
  27. /*
  28. bool right_turn(point a, point b, point c)
  29. {
  30. return ( (a.ycoord()-b.ycoord())*(a.xcoord()-c.xcoord())
  31.          + (b.xcoord()-a.xcoord())*(a.ycoord()-c.ycoord()) >= 0)
  32.  }
  33. */
  34.  
  35. bool right_turn(point a, point b, point c)
  36. { segment s(a,b);
  37.   segment t(b,c);
  38.   return (s.angle(t) < 0);
  39.  }
  40.  
  41. bool left_turn(point a, point b, point c)
  42. { segment s(a,b);
  43.   segment t(b,c);
  44.   return (s.angle(t) > 0);
  45.  }
  46.  
  47.  
  48. line p_bisector(point p, point q)
  49. { line l(p,q);
  50.   double m_x = (p.xcoord() + q.xcoord())/2;
  51.   double m_y = (p.ycoord() + q.ycoord())/2;
  52.   point M(m_x,m_y);
  53.  
  54.   double alpha = l.angle();
  55.  
  56.   return line(M,alpha+M_PI_2);
  57.  
  58. }
  59.  
  60.  
  61.  
  62.  
  63.   
  64.