00001 /* 00002 //=======================================================// _\|/_ 00003 // __ _____ ___ ___ // /|\ 00004 // / | ^ | \ | ^ | \ // _\|/_ 00005 // \__ | / \ |___/ | / \ |___/ // /|\ 00006 // \ | /___\ | \ | /___\ | \ // _\|/_ 00007 // ___/ | / \ | \ |____ / \ |___/ // /|\ 00008 // // _\|/_ 00009 //=======================================================// /|\ 00010 */ 00011 00012 /* 00013 * c_stdinc.h: C version of the standard STARLAB include file 00014 *............................................................................. 00015 * version 1: Sep 1995 Steve McMillan 00016 * version 2: 00017 *............................................................................. 00018 * This file includes: 00019 * 1) new naming conventions to add to or replace existing names in C 00020 * 2) a string manipulation macro 00021 * 3) mathematical constants 00022 * 4) functions abs() min(,) max(,) 00023 * 5) macros to cast angular arguments in standard form 00024 *............................................................................. 00025 */ 00026 00027 #ifndef STDINC 00028 # define STDINC 00029 00030 #include <stdio.h> 00031 #include <stdlib.h> 00032 #include <math.h> 00033 #include <string.h> 00034 00035 /*============================================================================= 00036 ** Starlab version specification : 00037 **============================================================================= 00038 */ 00039 00040 #define STARLAB_VERSION "2.1" 00041 00042 00043 /*============================================================================= 00044 ** New naming conventions to add to or replace existing names in C : 00045 **============================================================================= 00046 */ 00047 00048 /*----------------------------------------------------------------------------- 00049 * real -- a more general name for the standard floating-point data type 00050 *----------------------------------------------------------------------------- 00051 */ 00052 00053 typedef double real; 00054 00055 /*----------------------------------------------------------------------------- 00056 * bool -- another name for int, to indicate use in logical operations 00057 *----------------------------------------------------------------------------- 00058 */ 00059 00060 typedef int bool; 00061 00062 /* Convenient definitions: */ 00063 00064 #define false 0 00065 #define FALSE 0 00066 #define true 1 00067 #define TRUE 1 00068 00069 /*----------------------------------------------------------------------------- 00070 * local -- a more descriptive name for variables or functions which 00071 * are invisible outside the file in which they are defined. 00072 *----------------------------------------------------------------------------- 00073 */ 00074 00075 #define local static 00076 00077 00078 /*============================================================================= 00079 ** A string manipulation macro : 00080 **============================================================================= 00081 */ 00082 /*----------------------------------------------------------------------------- 00083 * streq -- a macro which returns 1 if two strings are equal, 0 otherwise 00084 *----------------------------------------------------------------------------- 00085 */ 00086 00087 #define streq(x,y) (strcmp((x), (y)) == 0) 00088 00089 00090 /*============================================================================= 00091 ** Mathematical constants : 00092 **============================================================================= 00093 */ 00094 00095 /*----------------------------------------------------------------------------- 00096 * pi, etc. -- mathematical constants, as well as "infinity" 00097 *----------------------------------------------------------------------------- 00098 */ 00099 00100 #ifndef PI 00101 # define PI 3.14159265358979323846 00102 #endif 00103 #define TWO_PI (2 * (PI)) 00104 #define HALF_PI (0.5 * (PI)) 00105 #define ONE_THIRD 0.33333333333333333333 00106 #define ONE_SIXTH 0.16666666666666666667 00107 00108 #define VERY_LARGE_NUMBER 1e300 00109 00110 00111 /*============================================================================= 00112 ** Macros to cast angular arguments in standard form : 00113 **============================================================================= 00114 */ 00115 00116 /*----------------------------------------------------------------------------- 00117 * pos_angle -- recasts an angular variable into the range [0, TWO_PI) 00118 * sym_angle -- recasts an angular variable into the range [-PI, PI) 00119 * (recasting: transforming modulo 2 pi) 00120 * example: 00121 * to map an angular variable 'phi' into the smallest positive 00122 * value, use 00123 * 00124 * phi = pos_angle(phi); 00125 * 00126 * to map an angular variable 'phi' into the smallest value, 00127 * positive or negative, use 00128 * 00129 * phi = sym_angle(phi); 00130 * 00131 *----------------------------------------------------------------------------- 00132 */ 00133 00134 #define pos_angle(phi) ((phi) - TWO_PI * floor((phi)/TWO_PI )) 00135 #define sym_angle(phi) ((phi) - TWO_PI * floor(((phi)+PI)/TWO_PI )) 00136 00137 #endif