Article View: comp.windows.x
Article #24193Help! My arc has fallen, and it can't get up!
From: Joshua Osborne
Date: Fri, 28 Jun 1991 06:23
Date: Fri, 28 Jun 1991 06:23
58 lines
2339 bytes
2339 bytes
I am trying to draw the outline of a pie wedge. I (think I) am using the
formula from the Digital Press "X Windows System, C Library and protocall
reference" by Scheifler, Gettys & Newman. I coded it up like this:
#define RPI (64*180./3.14159)
#define PIPI (3.14159/2)
double ella(a, w, h)
double a;
int w, h;
{
double skew;
skew = atan(tan(a) * w/(h+0.0));
skew += (a < PIPI) ? 0 : (a < 3 * PIPI) ? (2*PIPI) : (4*PIPI);
return skew;
}
Then armed with only a filled-out XArc structure, and a semester of Trig 4
years stale, I attempted many variations along the lines of:
v2_pie(xa)
XArc *xa;
{
XPoint pts[3];
double s, c;
int r;
r = (xa->width + xa->height) / 4;
pts[1].x = xa->width / 2 + xa->x;
pts[1].y = xa->height / 2 + xa->y;
sincos(ella(xa->angle1/RPI, xa->width, xa->height), &s, &c);
pts[0].x = pts[1].x + xa->width/2 * c;
pts[0].y = pts[1].y + xa->height/2 * s;
sincos(ella((xa->angle1+xa->angle2)/RPI, xa->width, xa->height), &s, &c);
pts[2].x = pts[1].x + xa->width/2 * c;
pts[2].y = pts[1].y + xa->height/2 * s;
XSetFillStyle(dpy, drawGC, FillSolid);
XDrawLines(dpy, win, drawGC, pts, 3, CoordModeOrigin);
XDrawArcs(dpy, win, drawGC, xa, 1);
reset_a();
}
I compiled the program, ran it, and it failed. Miserably. It's output was
hideous. Women fainted. Small children ran away. Worst of all, the lines
that should have connected the arc endpoints had very little to do with the
arc endpoints.
Does anyone have any suggestions? How can I compute the xy position of the
arc's endpoints? Please mail to me; I will summarize any and all replies
to the net.
--
stripes@eng.umd.edu "Security for Unix is like
Josh_Osborne@Real_World,The Multitasking for MS-DOS"
"The dyslexic porgramer" - Kevin Lockwood
Technical Details
Message-ID:
<1991Jun28.062319.11565@eng.umd.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!mimsy!mojo.eng.umd.edu!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!purdue!haven.umd.edu!mimsy!mojo.eng.umd.edu!news From: stripes@eng.umd.edu (Joshua Osborne) Newsgroups: comp.windows.x Subject: Help! My arc has fallen, and it can't get up! Message-ID: <1991Jun28.062319.11565@eng.umd.edu> Date: 28 Jun 91 06:23:19 GMT Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 58