1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 Dr. David Kirkby, e-mail drkirkby at ntlworld.com
42 #include "definitions.h"
46 extern unsigned char **oddity;
48 void calculate_colour_data(double x, double xmax, int w, int h, int offset, unsigned char *image_dat, int image_type,
49 unsigned char *red, unsigned char *green, unsigned char *blue, double image_fiddle_factor)
51 if(image_type==COLOUR) /*Ex, Ey, V */
53 if(fabs(x) < 1e-9) /* This is a bit of a fiddle I admit, but */
54 { /* Is needed to prevent problems at 'small' values */
61 *red=255*pow(x/xmax,1.0/image_fiddle_factor);
69 *blue=255*pow(-x/xmax,1.0/image_fiddle_factor);
72 else if (image_type==MONOCHROME) /* E, energy, permittivity */
76 *red=0; *green=0; *blue=0;
80 *red=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
81 *green=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
82 *blue=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
85 else if (image_type==MIXED) /* Only for permittivity*/
87 if(oddity[w][h]==CONDUCTOR_ZERO_V)
89 *red=0; *green=255; *blue=0;
91 else if(oddity[w][h]==CONDUCTOR_PLUS_ONE_V)
93 *red=255; *green=0; *blue=0;
95 else if(oddity[w][h]==CONDUCTOR_MINUS_ONE_V)
97 *red=0; *green=0; *blue=255;
101 *red=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
102 *green=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
103 *blue=255*pow(fabs(x/xmax),1.0/image_fiddle_factor);
106 image_dat[offset]=*blue;
107 image_dat[offset+1]=*green;
108 image_dat[offset+2]=*red;