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

fixedpoint.h File Reference

16.16 fixed point math functions. More...

Go to the source code of this file.

Defines

#define FIXED_METER   FIXED_POINT
#define INT_TO_FIXED(x)   ((x) << 16)
#define DOUBLE_TO_FIXED(x)   ((long)((x) * 65536.0 + 0.5))
#define FIXED_TO_INT(x)   ((x) >> 16)
#define FIXED_TO_DOUBLE(x)   (((double)x) / 65536.0)
#define ROUND_FIXED_TO_INT(x)   (((x) + 0x8000) >> 16)
#define FIXED_ONE   INT_TO_FIXED(1)
#define FIXED_TWO   0x20000L
#define FIXED_FOUR   0x40000L
#define FIXED_8   0x80000L
#define FIXED_10   0xA0000L
#define FIXED_1000   0x3E80000L
#define FIXED_90   0x5A0000L
#define FIXED_180   0xB40000L
#define FIXED_MINUS_1   -65536L
#define FIXED_RADIAN_CONVERSION   0x478L
#define FIXED_DEGREE_CONVERSION   0x394C4AL
#define FIXED_POINT_1   DOUBLE_TO_FIXED(0.1)
#define FIXED_POINT_005   DOUBLE_TO_FIXED(0.005)
#define FIXED_POINT_03   DOUBLE_TO_FIXED(0.03)
#define FIXED_POINT_35   DOUBLE_TO_FIXED(0.35)
#define FIXED_POINT_15   DOUBLE_TO_FIXED(0.15)
#define FIXED_POINT_1_1   DOUBLE_TO_FIXED(1.1)
#define FIXED_PIDIV4   51472L
#define FIXED_PIDIV2   102944L
#define FIXED_PI   205887L
#define FIXED_2PI   411775L
#define FIXED_E   178144L
#define FIXED_LN2   45426L
#define FIXED_SQRT2   92682L

Typedefs

typedef int32 FIXED_POINT
typedef FIXED_POINT FIXED_RADIAN
typedef FIXED_POINT FIXED_MILLIMETER
typedef FIXED_POINT FIXED_WRENCH_EFFORT
typedef FIXED_POINT FIXED_SPEED
typedef FIXED_POINT FIXED_CENTIMETER

Functions

int32 fpmul (int32 x, int32 y)
int32 fpdiv (int32 x, int32 y)
int32 fpsqrt (int32 x)
int32 fpsin (int32 x)
int32 fpcos (int32 x)
int32 fptan (int32 x)
int32 fpatan (int32 x)
int32 fpexp (int32 x)
int32 fpln (int32 x)


Detailed Description

16.16 fixed point math functions.

This file contains the global function prototypes, macros, and numerical constants for the libfixed fixed point math library.

To use the functions defined in this file, include <68332/fixedpoint.h> and link libfixed.a.


Define Documentation

#define DOUBLE_TO_FIXED  )     ((long)((x) * 65536.0 + 0.5))
 

#define FIXED_10   0xA0000L
 

#define FIXED_1000   0x3E80000L
 

#define FIXED_180   0xB40000L
 

#define FIXED_2PI   411775L
 

#define FIXED_8   0x80000L
 

#define FIXED_90   0x5A0000L
 

#define FIXED_DEGREE_CONVERSION   0x394C4AL
 

#define FIXED_E   178144L
 

#define FIXED_FOUR   0x40000L
 

#define FIXED_LN2   45426L
 

#define FIXED_METER   FIXED_POINT
 

#define FIXED_MINUS_1   -65536L
 

#define FIXED_ONE   INT_TO_FIXED(1)
 

#define FIXED_PI   205887L
 

#define FIXED_PIDIV2   102944L
 

#define FIXED_PIDIV4   51472L
 

#define FIXED_POINT_005   DOUBLE_TO_FIXED(0.005)
 

#define FIXED_POINT_03   DOUBLE_TO_FIXED(0.03)
 

#define FIXED_POINT_1   DOUBLE_TO_FIXED(0.1)
 

#define FIXED_POINT_15   DOUBLE_TO_FIXED(0.15)
 

#define FIXED_POINT_1_1   DOUBLE_TO_FIXED(1.1)
 

#define FIXED_POINT_35   DOUBLE_TO_FIXED(0.35)
 

#define FIXED_RADIAN_CONVERSION   0x478L
 

#define FIXED_SQRT2   92682L
 

#define FIXED_TO_DOUBLE  )     (((double)x) / 65536.0)
 

#define FIXED_TO_INT  )     ((x) >> 16)
 

#define FIXED_TWO   0x20000L
 

#define INT_TO_FIXED  )     ((x) << 16)
 

#define ROUND_FIXED_TO_INT  )     (((x) + 0x8000) >> 16)
 


Typedef Documentation

typedef FIXED_POINT FIXED_CENTIMETER
 

typedef FIXED_POINT FIXED_MILLIMETER
 

typedef int32 FIXED_POINT
 

typedef FIXED_POINT FIXED_RADIAN
 

typedef FIXED_POINT FIXED_SPEED
 

typedef FIXED_POINT FIXED_WRENCH_EFFORT
 


Function Documentation

int32 fpatan int32  x  ) 
 

Calculates the arctangent of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The return value will be in the range of -FIXED_PI/2 to FIXED_PI/2

Parameters:
x The input value.
Returns:
The arctangent of x in radians.

int32 fpcos int32  x  ) 
 

Calculates the cosine of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI.

Parameters:
x The input value in radians.
Returns:
The cosine of x.

int32 fpdiv int32  x,
int32  y
 

Divides a 16.16 fixed point dividend by a 16.16 fixed point divisor, returning a 16.16 fixed point quotient. Note: No checking for underflow is performed.

Parameters:
x The dividend.
y The divisor.
Returns:
The quotient.

int32 fpexp int32  x  ) 
 

Calculates the base e exponential of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for overflow is performed.

Parameters:
x The input value.
Returns:
The exponential result.

int32 fpln int32  x  ) 
 

Calculates the base e logarithm of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for underflow is performed.

Parameters:
x The input value.
Returns:
The logarithm result.

int32 fpmul int32  x,
int32  y
 

Multiplies two 16.16 fixed point numbers together, returning a 16.16 fixed point product. Note: No checking for overflow is performed.

Parameters:
x The first multiplicand.
y The second multiplicand.
Returns:
The product.

int32 fpsin int32  x  ) 
 

Calculates the sine of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI.

Parameters:
x The input value in radians.
Returns:
The sine of x.

int32 fpsqrt int32  x  ) 
 

Calculates the square root of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: No checking for underflow is performed.

Parameters:
x The input value.
Returns:
The square root.

int32 fptan int32  x  ) 
 

Calculates the tangent of a 16.16 fixed point number, returning a 16.16 fixed point result. Note: The input will be transformed to within the range of -FIXED_PI to +FIXED_PI. Note: The return value will be in the range of -32768.0 to 32767.999984741

Parameters:
x The input value in radians.
Returns:
The tangent of x.


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