#ifndef UTIL_H # define UTIL_H # include # ifndef M_PI # define M_PI 3.14159265358979323846 # endif # define SIZE(someArray) ( sizeof(someArray) / sizeof(someArray[0]) ) typedef struct { double mX; double mY; } XY; // ------------------------------------------------------------- // Open: 'fileName' with mode: 'mode', returns a FILE * or NULL // if the file could not be opened // ------------------------------------------------------------- FILE *utilOpenFile(const char *fileName, const char *mode); // ------------------------------------------------------------- // Return random value, initializes srand when first called // ------------------------------------------------------------- int utilRandomValue(void); // ------------------------------------------------------------- // Convert 'degrees' to radians // ------------------------------------------------------------- double utilDegreesToRadians(double degrees); // ------------------------------------------------------------- // Find the (x, y) point that's a distance of 'radius' away // from (xOffset, yOffset) with direction: 'degrees' // ------------------------------------------------------------- XY utilGetXY(double degrees, double radius, double xOffset, double yOffset); // ------------------------------------------------------------- // Round 'value' to integer // ------------------------------------------------------------- int utilRound(double value); // ------------------------------------------------------------- // Get the current hour, minute and second // ------------------------------------------------------------- void utilGetHMS(int *hourPtr, int *minutePtr, int *secondPtr); #endif