Main Page | Modules | Data Structures | File List | Data Fields | Globals

fixedpoint.h

Go to the documentation of this file.
00001 /*
00002  * $Id: fixedpoint.h,v 1.4 2004/02/07 15:47:41 dasmith Exp $
00003  *
00004  * fixedpoint.h - Fixed point library routines to perform
00005  *                16.16 fixed point math.
00006  *
00007  * Copyright (C) 2003 David A. Smith
00008  *
00009  * This library is distributed under the terms of the GNU Lesser General
00010  * Public License (LGPL).  You should have received a copy of the
00011  * license along with this library (LGPL.txt); if not, write to
00012  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00013  * Boston, MA  02111-1307  USA
00014  */
00015 
00032 #ifndef __FIXEDPOINT_H__
00033 #define __FIXEDPOINT_H__
00034 
00035 #include <68332/types.h>
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 #define INT_TO_FIXED(x)         ((x) << 16)
00042 #define DOUBLE_TO_FIXED(x)      ((long)((x) * 65536.0 + 0.5))
00043 #define FIXED_TO_INT(x)         ((x) >> 16)
00044 #define FIXED_TO_DOUBLE(x)      (((double)(x)) / 65536.0)
00045 #define ROUND_FIXED_TO_INT(x)   (((x) + 0x8000) >> 16)
00046 
00047 #define FIXED_ONE       INT_TO_FIXED(1)
00048 #define FIXED_PIDIV4     51472L
00049 #define FIXED_PIDIV2    102944L
00050 #define FIXED_PI        205887L
00051 #define FIXED_2PI       411775L
00052 #define FIXED_E         178144L
00053 #define FIXED_LN2        45426L
00054 #define FIXED_SQRT2              92682L
00055 
00056 #ifndef FLOAT_PI
00057 #define FLOAT_PI 3.141592654
00058 #endif
00059 
00071 int32 fpmul(int32 x, int32 y);
00072 
00084 int32 fpdiv(int32 x, int32 y);
00085 
00095 int32 fpsqrt(int32 x);
00096 
00107 int32 fpsin(int32 x);
00108 
00119 int32 fpcos(int32 x);
00120 
00133 int32 fptan(int32 x);
00134 
00145 int32 fpatan(int32 x);
00146 
00156 int32 fpexp(int32 x);
00157 
00167 int32 fpln(int32 x);
00168 
00169 #ifdef __cplusplus
00170 }
00171 #endif
00172 
00173 #endif

Generated on Wed Sep 6 03:02:21 2006 for MotoRobots by doxygen 1.3.6