Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

fixedpoint.h

Go to the documentation of this file.
00001 /*
00002  * $Id: fixedpoint.h,v 1.2 2006/07/16 06:11:17 derek 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 #include <hardware/types.h>
00035 typedef int32 FIXED_POINT;
00036 typedef FIXED_POINT FIXED_RADIAN;
00037 typedef FIXED_POINT FIXED_MILLIMETER;
00038 typedef FIXED_POINT FIXED_WRENCH_EFFORT;
00039 typedef FIXED_POINT FIXED_SPEED;
00040 typedef FIXED_POINT FIXED_CENTIMETER;
00041 //  #define FIXED_CENTIMETER FIXED_POINT
00042 //  #define FIXED_SPEED FIXED_POINT
00043 //  #define FIXED_MILLIMETER FIXED_POINT
00044   #define FIXED_METER      FIXED_POINT
00045 //  #define FIXED_POSITION FIXED_POINT
00046 //  #define FIXED_RADIAN FIXED_POINT
00047 //  #define FIXED_DEGREE FIXED_POINT
00048 //  #define FIXED_WRENCH_EFFORT FIXED_POINT
00049 
00050 
00051 //#define FIXED_POINT int32
00052 
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056 
00057 #define INT_TO_FIXED(x)         ((x) << 16)
00058 #define DOUBLE_TO_FIXED(x)      ((long)((x) * 65536.0 + 0.5))
00059 #define FIXED_TO_INT(x)         ((x) >> 16)
00060 #define FIXED_TO_DOUBLE(x)      (((double)x) / 65536.0)
00061 #define ROUND_FIXED_TO_INT(x)   (((x) + 0x8000) >> 16)
00062 
00063 #define FIXED_ONE       INT_TO_FIXED(1)
00064 #define FIXED_TWO       0x20000L
00065 #define FIXED_FOUR      0x40000L
00066 #define FIXED_8         0x80000L
00067 #define FIXED_10        0xA0000L
00068 #define FIXED_1000      0x3E80000L
00069 #define FIXED_90        0x5A0000L
00070 #define FIXED_180       0xB40000L
00071 #define FIXED_MINUS_1   -65536L
00072 /* DOUBLE_TO_FIXED(RADIAN_CONVERSION) */
00073 /* DOUBLE_TO_FIXED(DEGREE_CONVERSION) */
00074 #define FIXED_RADIAN_CONVERSION 0x478L 
00075 #define FIXED_DEGREE_CONVERSION 0x394C4AL
00076 #define FIXED_POINT_1   DOUBLE_TO_FIXED(0.1)
00077 #define FIXED_POINT_005 DOUBLE_TO_FIXED(0.005)
00078 #define FIXED_POINT_03  DOUBLE_TO_FIXED(0.03)
00079 #define FIXED_POINT_35  DOUBLE_TO_FIXED(0.35)
00080 #define FIXED_POINT_15  DOUBLE_TO_FIXED(0.15)
00081 #define FIXED_POINT_1_1  DOUBLE_TO_FIXED(1.1)
00082 #define FIXED_PIDIV4     51472L
00083 #define FIXED_PIDIV2    102944L
00084 #define FIXED_PI        205887L
00085 #define FIXED_2PI       411775L
00086 #define FIXED_E         178144L
00087 #define FIXED_LN2        45426L
00088 #define FIXED_SQRT2              92682L
00089 
00101 int32 fpmul(int32 x, int32 y);
00102 
00114 int32 fpdiv(int32 x, int32 y);
00115 
00125 int32 fpsqrt(int32 x);
00126 
00137 int32 fpsin(int32 x);
00138 
00149 int32 fpcos(int32 x);
00150 
00163 int32 fptan(int32 x);
00164 
00175 int32 fpatan(int32 x);
00176 
00186 int32 fpexp(int32 x);
00187 
00197 int32 fpln(int32 x);
00198 
00199 #ifdef __cplusplus
00200 }
00201 #endif
00202 
00203 #endif

Generated on Mon Oct 8 19:32:18 2007 for OOMRM Mapping API by doxygen1.3