Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "plplotP.h"
00023
00024 #define CIRCLE_SEGMENTS ( PL_MAXPOLY - 1 )
00025 #define DEG_TO_RAD( x ) ( ( x ) * M_PI / 180.0 )
00026
00027
00028
00029
00030
00031
00032
00033 void
00034 plarc_approx( PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, PLFLT rotate, PLBOOL fill )
00035 {
00036 PLINT i;
00037 PLFLT theta0, theta_step, theta, d_angle;
00038 PLINT segments;
00039 PLFLT xs[CIRCLE_SEGMENTS + 1], ys[CIRCLE_SEGMENTS + 1];
00040 PLFLT cphi, sphi, ctheta, stheta;
00041
00042
00043 d_angle = DEG_TO_RAD( angle2 - angle1 );
00044 if ( fabs( d_angle ) > M_PI * 2.0 )
00045 d_angle = M_PI * 2.0;
00046
00047
00048 cphi = cos( DEG_TO_RAD( rotate ) );
00049 sphi = sin( DEG_TO_RAD( rotate ) );
00050
00051
00052 segments = fabs( d_angle ) / ( 2.0 * M_PI ) * CIRCLE_SEGMENTS;
00053
00054 if ( segments < 2 )
00055 segments = 2;
00056
00057
00058 theta0 = DEG_TO_RAD( angle1 );
00059
00060 theta_step = d_angle / ( segments - 1 );
00061
00062
00063 for ( i = 0; i < segments; i++ )
00064 {
00065 theta = theta0 + theta_step * (PLFLT) i;
00066 ctheta = cos( theta );
00067 stheta = sin( theta );
00068 xs[i] = x + a * ctheta * cphi - b * stheta * sphi;
00069 ys[i] = y + a * ctheta * sphi + b * stheta * cphi;
00070 }
00071
00072 if ( fill )
00073 {
00074
00075 if ( fabs( d_angle ) < M_PI * 2.0 )
00076 {
00077 xs[segments] = x;
00078 ys[segments] = y;
00079 segments++;
00080 }
00081
00082 plfill( segments, xs, ys );
00083 }
00084 else
00085 {
00086
00087 plline( segments, xs, ys );
00088 }
00089 }
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 void
00113 c_plarc( PLFLT x, PLFLT y, PLFLT a, PLFLT b, PLFLT angle1, PLFLT angle2, PLFLT rotate, PLBOOL fill )
00114 {
00115 PLINT xscl[2], yscl[2];
00116 PLINT clpxmi, clpxma, clpymi, clpyma;
00117 arc_struct *arc_info;
00118
00119
00120 if ( plsc->dev_arc && plsc->diorot == 0 )
00121 {
00122 arc_info = (arc_struct *) malloc( (size_t) sizeof ( arc_struct ) );
00123
00124 xscl[0] = plP_wcpcx( x - a );
00125 xscl[1] = plP_wcpcx( x + a );
00126 yscl[0] = plP_wcpcy( y - b );
00127 yscl[1] = plP_wcpcy( y + b );
00128 difilt( xscl, yscl, 2, &clpxmi, &clpxma, &clpymi, &clpyma );
00129
00130 arc_info->x = 0.5 * ( xscl[1] + xscl[0] );
00131 arc_info->y = 0.5 * ( yscl[1] + yscl[0] );
00132 arc_info->a = 0.5 * ( xscl[1] - xscl[0] );
00133 arc_info->b = 0.5 * ( yscl[1] - yscl[0] );
00134
00135 arc_info->angle1 = angle1;
00136 arc_info->angle2 = angle2;
00137 arc_info->rotate = rotate;
00138 arc_info->fill = fill;
00139
00140 plP_esc( PLESC_ARC, arc_info );
00141
00142 free( arc_info );
00143 }
00144 else
00145 {
00146 plarc_approx( x, y, a, b, angle1, angle2, rotate, fill );
00147 }
00148 }
00149