run_utils.c

00001 /*
00002   走行制御の補助関数
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 #define C_RUNCTRL_SOURCE
00007 
00008 #include "run_utils.h"
00009 #include "detect_os.h"
00010 #if defined Linux || defined NoSDL_Linux
00011 #include <unistd.h>
00012 #elif defined WINDOWS
00013 #include <windows.h>
00014 #endif
00015 
00016 #include <math.h>
00017 #include "math_util.h"
00018 
00019 
00026 int deg(int degree) {
00027   return (int)(65536 * degree / 360);
00028 }
00029 
00030 
00037 int rad(double radian) {
00038   return (int)(65536 * radian / (2.0 * M_PI));
00039 }
00040 
00041 
00048 int to_deg(int div16) {
00049   return (360 * div16 / 65536);
00050 }
00051 
00052 
00059 double to_rad(int div16) {
00060   return (2.0 * M_PI * div16 / 65536.0);
00061 }
00062 
00063 
00070 int sec(double second) {
00071   return (1000.0 * second);
00072 }
00073 
00074 
00081 void mWait(int msec) {
00082 #ifdef __linux__
00083   usleep(1000 * msec);
00084 #elif __WIN32__ || _MBCS
00085   Sleep(msec);
00086 #endif
00087 }
00088 

Generated on Mon Apr 13 22:52:04 2009 by  doxygen 1.5.7.1