implement Arc() for plot5 and hpgl (smith diagram)

This commit is contained in:
rlar 2010-08-02 16:31:35 +00:00
parent 1657b33535
commit eaef9ffd7a
3 changed files with 53 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2010-08-02 Robert Larice
* src/frontend/hpgl.c ,
* src/frontend/plotting/plot5.c :
implement Arc() for plot5 and hpgl (smith diagram)
2010-08-01 Holger Vogt
* autogen.sh: update for adms

View File

@ -226,23 +226,16 @@ int GL_Arc(
int x0, int y0, int r,
double theta, double delta_theta)
{
/*
double x1, y1;
double angle1, angle2;
int x1, y1, angle;
while (theta1 >= theta2)
theta2 += 2 * M_PI;
x1 = x0 + r * cos(theta);
y1 = y0 + r * sin(theta);
angle1 = (double) (RAD_TO_DEG * theta1);
angle2 = (double) (RAD_TO_DEG * theta2);
x1 = (double) x0 + r * cos(theta1);
y1 = (double) y0 + r * sin(theta1);
angle = RAD_TO_DEG * delta_theta;
fprintf(plotfile, "PU;PA %d , %d;", jgmult*(x1+xoff+XTADJ), jgmult*(y1+yoff+YTADJ));
fprintf(plotfile, "PD;AA %d , %d, %d;", jgmult*(x0+xoff+XTADJ), jgmult*(y0+yoff+YTADJ), angle);
fprintf(plotfile, "%lf %lf moveto ", x1+(double)xoff, y1+(double)yoff);
fprintf(plotfile, "%d %d %d %lf %lf arc\n", x0+xoff, y0+yoff, r,
angle1, angle2);
fprintf(plotfile, "stroke\n");
*/
DEVDEP(currentgraph).linecount = 0;
return 0;

View File

@ -114,10 +114,49 @@ Plt5_DrawLine(int x1, int y1, int x2, int y2)
return 0;
}
/* ARGSUSED */ /* until some code gets written */
int
Plt5_Arc(int x0, int y0, int radius, double theta, double delta_theta)
Plt5_Arc(int xc, int yc, int radius, double theta, double delta_theta)
{
int x0,y0,x1,y1;
if(delta_theta < 0) {
theta += delta_theta;
delta_theta = -delta_theta;
}
if((2*M_PI - delta_theta)*radius < 0.5) {
putc('c', plotfile);
putsi(xc);
putsi(yc);
putsi(radius);
return 0;
}
while(delta_theta*radius > 0.5) {
double delta_phi = M_PI/2;
if(delta_phi > delta_theta)
delta_phi = delta_theta;
x0 = xc + (radius * cos(theta));
y0 = yc + (radius * sin(theta));
x1 = xc + (radius * cos(theta + delta_phi));
y1 = yc + (radius * sin(theta + delta_phi));
putc('a', plotfile);
putsi(xc);
putsi(yc);
putsi(x0);
putsi(y0);
putsi(x1);
putsi(y1);
delta_theta -= delta_phi;
theta += delta_phi;
}
return 0;
}