home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / plot / plot2ps.sha / arc.c next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  1.4 KB  |  46 lines

  1. /*
  2.     This file is part of plot2ps.
  3.  
  4.     Copyright (C) 1989 Rene' Seindal
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 1, or (at your option)
  9.     any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.     My current address is: seindal@diku.dk
  21. */
  22.  
  23. #include "defs.h"
  24.  
  25. #define PI  ((double)3.14159265358979323844)
  26. #define radtodeg(x)  ((double)(x)*180.0/PI)
  27.  
  28. arc(x, y, x0, y0, x1, y1)
  29. {
  30.     double theta0, theta1, rad;
  31.     int rx0, ry0, rx1, ry1;
  32.  
  33.     rx0 = x0 - x;
  34.     ry0 = y0 - y;
  35.     rx1 = x1 - x;
  36.     ry1 = y1 - y;
  37.  
  38.     rad = hypot( X(x0) - X(x), Y(y0) - Y(y) );
  39.     theta0 = (rx0 == 0) ? 180.0 : radtodeg( atan2((double)ry0, (double)rx0) );
  40.     theta1 = (rx1 == 0) ? 180.0 : radtodeg( atan2((double)ry1, (double)rx1) );
  41.  
  42.     clear();
  43.     printf( "%g %g %g %g %g arc\n", X(x), Y(y), rad, theta0, theta1 );
  44.     DIRTYPATH;
  45. }
  46.