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