home *** CD-ROM | disk | FTP | other *** search
- /* «RM120»«PL99999»«TS4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76» */
- #include <stdio.h>
- #define EXTERN extern
- #include <typedef.h>
-
-
- #define PI 3.1415298
-
-
- void ClippedLine(x1, y1, x2, y2)
- int x1, y1, x2, y2;
- {
- if (clip(&x1, &y1, &x2, &y2))
- DrawLine((double)x1, (double)y1, (double)x2, (double)y2);
- }
-
-
- void ClippedPoint(x,y)
- int x, y;
- {
- if (ClippingGlb) {
- if ((x >= X1RefGlb << 3) && (x < X2RefGlb << 3 + 7) &&
- (y >= Y1RefGlb) && (y <= Y2RefGlb))
- DP(x, y);
- }
- else
- DP(x, y);
- }
-
-
- void DrawCircleSegment(xr0,yr0,xr1,yr1,inner,outer,phi,area,txt,option,scale)
- double xr0,yr0,*xr1,*yr1,inner,outer,phi,area;
- char *txt;
- int option, scale;
- {
- extern double fabs();
- extern double sin(), cos(), atan();
- extern double square(), sqrt();
-
-
- double FaktC,FaktS,CDummy,c,s,radius;
- double Phi1,DeltaPhi,CosPhi,SinPhi,CosDphi,SinDphi;
- double DeltaX,DeltaY,xr2,yr2,RadiusLoc,X0Loc,Y0Loc,X1Loc,Y1Loc;
- int i,AsciiCode,TextLen,n,x0,y0,x1,y1,x2,y2;
- int DirectModeLoc;
- WrkString TempText, T2Text;
-
- X0Loc = xr0;
- Y0Loc = yr0;
- X1Loc = *xr1;
- Y1Loc = *yr1;
- RadiusLoc = sqrt(square(X1Loc-X0Loc)+square(Y1Loc-Y0Loc));
-
- if (RadiusLoc <= 0.0)
- return;
-
- option = iabs(option);
- inner = fabs(inner);
- outer = fabs(outer);
- scale = iabs(scale);
- DirectModeLoc = DirectModeGlb;
- DirectModeGlb = TRUE;
-
- phi = phi * PI / 180.0;
- if (fabs(phi)/(2.0 * PI) > 1.0)
- phi = 2.0 * PI;
-
- n = (int)(RadiusLoc * fabs(phi) / 9.0);
- if (n < 2)
- n = 2;
-
- if ((fabs(*xr1 - xr0) > 0.) && (fabs(*yr1 - yr0) > 0.))
- Phi1 = atan((*yr1 - yr0) / (*xr1 - xr0));
- else {
- if (*xr1-xr0 == 0.) {
- if (*yr1-yr0 > 0)
- Phi1 = 0.5 * PI;
- else
- Phi1 = 1.5 * PI;
- }
- else if (*xr1 > xr0)
- Phi1 = 0.0;
- else
- Phi1 = PI;
- }
- DeltaPhi = phi/(n-1);
- c = 1.0;
- s = 0.0;
- CosPhi = cos(Phi1);
- SinPhi = sin(Phi1);
- CosDphi = cos(DeltaPhi);
- SinDphi = sin(DeltaPhi);
- if (*xr1 < xr0) {
- FaktS = -1;
- FaktC = -1;
- }
- else {
- FaktS = 1;
- FaktC = 1;
- }
- if ((*yr1 == yr0) && (*xr1 < xr0)) {
- FaktC = -FaktC;
- FaktS = -FaktS;
- }
- if (area < 0) {
- area = fabs(area);
- DeltaX = FaktC * 0.3 * RadiusLoc * cos(phi / 2. + Phi1);
- DeltaY = (int)(FaktS * 0.3 * AspectGlb * RadiusLoc
- * sin(phi / 2. + Phi1) + 0.5);
- xr0 = xr0 + DeltaX;
- yr0 = yr0 + DeltaY;
- }
- x0 = WindowX(xr0);
- y0 = WindowY(yr0);
- if (!DirectModeLoc)
- ClippedPoint(x0, y0);
- else
- DP(x0, y0);
- x1 = x0;
- y1 = y0;
- for (i = 1; i <= n; i++ ) {
- xr2 = xr0 + FaktC * RadiusLoc * (CosPhi * c - SinPhi * s);
- x2 = WindowX(xr2);
- yr2 = yr0 + AspectGlb * RadiusLoc * FaktS
- * (SinPhi * c + CosPhi * s);
- y2 = WindowY(yr2);
- if (!DirectModeLoc)
- ClippedLine(x1, y1, x2, y2);
- else
- DrawLineDirect(x1, y1, x2, y2);
- x1 = x2;
- y1 = y2;
- CDummy = c * CosDphi - s * SinDphi;
- s = s * CosDphi + c * SinDphi;
- c = CDummy;
- }
- if (!PieGlb) {
- if (!DirectModeLoc)
- ClippedLine(x1, y1, x0, y0);
- else
- DrawLine(x1, y1, x0, y0);
- }
- if ((option > 0) && (phi < 2.0 * PI)) {
- *xr1 = xr0 + FaktC * RadiusLoc * inner * cos(phi / 2.0 + Phi1);
- *yr1 = yr0 + FaktS * AspectGlb * RadiusLoc * inner
- *sin(phi/2.0+Phi1);
- xr2 = xr0 + FaktC * RadiusLoc * outer * cos(phi / 2.0 + Phi1);
- yr2 = yr0 + FaktS * AspectGlb * RadiusLoc * outer
- * sin(phi / 2.0 + Phi1);
- x1 = WindowX(*xr1);
- y1 = WindowY(*yr1);
- x2 = WindowX(xr2);
- y2 = WindowY(yr2);
- if (!DirectModeLoc)
- ClippedLine(x1, y1, x2, y2);
- else
- DrawLineDirect( x1, y1, x2, y2);
- sprintf(T2Text, "%4.2lf", area);
- switch (option) {
- case 1:
- strcpy(TempText, txt);
- break;
-
- case 2:
- strcpy(TempText, txt);
- strcat(TempText, T2Text);
- break;
-
- case 3:
- strcpy(TempText, T2Text);
- break;
- }
- TextLen = strlen(TempText);
- if (x2 >= x0)
- x2 = x2 + scale * 6;
- else
- x2 = x2 - TextLen * 6 * scale;
- DrawText(x2, y2, scale, TempText);
- }
- *xr1 = X0Loc + FaktC * RadiusLoc * cos(phi + Phi1);
- *yr1 = Y0Loc + FaktS * RadiusLoc * sin(phi + Phi1);
- DirectModeGlb = DirectModeLoc;
- }
-