Jspice3
mfbarc.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Thomas L. Quarles
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 #include "mfb.h"
9 #include "mfbp.h"
10 
11 #define RadToDeg 57.29577951
12 
13 void
14 MFBArc(x,y,r,astart,astop,s)
15 
16 int x; /* x coordinate of center */
17 int y; /* y coordinate of center */
18 int r; /* radius of arc */
19 int astart; /* initial angle ( +x axis = 0 degrees ) */
20 int astop; /* final angle ( +x axis = 0 degrees ) */
21 int s; /* number of segments in a 360 degree arc */
22 /*
23  * Notes:
24  * Draws an arc of radius r and center at (x,y) beginning at
25  * angle astart (in degrees) and ending at astop
26  */
27 
28 {
29  int i,j;
30  double d = astart / RadToDeg;
31 
32  MFBMoveTo(x + (int)(r * cos(d)),y + (int)(r * sin(d)));
33 
34  while (astart >= astop)
35  astop += 360;
36 
37  if (s <= 2 || s > 180)
38  s = 18;
39 
40  j = (astop - astart)/s;
41 
42  if (!j)
43  j++;
44 
45  for (i = astart + j; i <= astop; i += j) {
46  d = i / RadToDeg;
47  MFBDrawLineTo(x + (int)(r * cos(d)), y + (int)(r * sin(d)));
48  }
49  d = astop / RadToDeg;
50  MFBDrawLineTo(x + (int)(r * cos(d)), y + (int)(r * sin(d)));
51 }
void MFBArc(int x, int y, int r, int astart, int astop, int s)
Definition: mfbarc.c:14
Definition: cddefs.h:119
#define RadToDeg
Definition: mfbarc.c:11
Definition: cddefs.h:237
double cos()
void MFBDrawLineTo()
double sin()
Definition: cddefs.h:162
void MFBMoveTo()