[GRASS5] D.vect.graph problem
Moritz Lennert
mlennert at club.worldonline.be
Wed Sep 22 08:41:29 EDT 2004
On Tue, September 21, 2004 20:03, Glynn Clements said:
>
> Michael Barton wrote:
>
>> Indeed, there are some cases for which all columns used in the pie chart
>> would be zero. Do I need to filter these out? Perhaps the pie chart
>> algorithm should automatically filter these out if it is problematic??
>
> The algorithm needs to iterate for a fixed number of steps. Try the
> attached patch.
This seems to do the trick. Everything works perfectly here now.
Thanks !
Moritz
>
> --
> Glynn Clements <glynn.clements at virgin.net>
>
> --- pie.c~ Sun Sep 5 08:20:31 2004
> +++ pie.c Tue Sep 21 18:58:25 2004
> @@ -11,7 +11,7 @@
> int
> pie ( double cx, double cy, int size, double *val, int ncols, COLOR
> *ocolor, COLOR *colors )
> {
> - int i, j;
> + int i, j, n;
> double a, end_ang, ang, tot_sum, sum, step, r;
> double x, y;
> struct line_pnts *Points;
> @@ -36,20 +36,15 @@
> if (val[0] != tot_sum) /* all in one slice, don't draw line to center */
> Vect_append_point ( Points, cx, cy, 0);
>
> - a = ang;
> - while ( 1 ) {
> + n = (int)ceil((end_ang - ang) / step);
> + for (j = 0, a = ang; j <= n; j++, a += step)
> + {
> if ( a > end_ang ) a = end_ang;
> x = cx + r * cos ( a );
> y = cy + r * sin ( a );
> Vect_append_point ( Points, x, y, 0);
> -
> - if ( a == end_ang ) {
> - ang = end_ang;
> - break;
> - } else {
> - a += step;
> - }
> }
> + ang = end_ang;
>
> if (val[0] != tot_sum)
> Vect_append_point ( Points, cx, cy, 0);
>
More information about the grass-dev
mailing list