icon.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 #include <math.h>
00003 #include <grass/gis.h>
00004 
00005 static int trans ( double *x, double *y, int n_points, double angle, double scale, 
00006                      double xc, double yc ) {
00007     int i;
00008     double r, a;
00009 
00010     for ( i = 0; i < n_points; i++) {
00011         r = scale * hypot ( x[i], y[i] );
00012         a = atan2 ( y[i], x[i] );
00013         a += angle;   
00014         x[i] = r * cos(a) + xc;
00015         y[i] = r * sin(a) + yc;
00016     }
00017 
00018     return 1;
00019 }
00020 
00021 /* Plot icon */
00022 int G_plot_icon (double xc, double yc, int type, double angle, double scale) 
00023 {
00024     int    i, np = 0;
00025     double x[10], y[10];
00026     
00027     
00028     /* diamond, box */
00029     switch(type) {
00030         case G_ICON_CROSS: 
00031             x[0] = -0.5; y[0] =  0.0;
00032             x[1] =  0.5; y[1] =  0.0;
00033             x[2] =  0.0; y[2] = -0.5;
00034             x[3] =  0.0; y[3] =  0.5;
00035             np = 4;
00036             break;
00037         case G_ICON_BOX: 
00038              G_debug (1, "box");
00039             x[0] = -0.5; y[0] = -0.5;
00040             x[1] =  0.5; y[1] = -0.5;
00041             x[2] =  0.5; y[2] = -0.5;
00042             x[3] =  0.5; y[3] =  0.5;
00043             x[4] =  0.5; y[4] =  0.5;
00044             x[5] = -0.5; y[5] =  0.5;
00045             x[6] = -0.5; y[6] =  0.5;
00046             x[7] = -0.5; y[7] = -0.5;
00047             np = 8;
00048             break;
00049         case G_ICON_ARROW: 
00050             x[0] = -1; y[0] =  0.5;
00051             x[1] =  0; y[1] =  0.0;
00052             x[2] = -1; y[2] = -0.5;
00053             x[3] =  0; y[3] =  0.0;
00054             np = 4;
00055             break;
00056     }
00057     
00058     trans ( x, y, np, angle, scale, xc, yc);
00059             
00060     for ( i = 0; i < np; i += 2 )
00061         G_plot_line(x[i], y[i], x[i+1], y[i+1]);
00062                 
00063     return (1);
00064 }
00065 

Generated on Fri Nov 21 11:02:18 2008 for GRASS by  doxygen 1.5.1