IwGeomCore
[IwGeom API Reference]


Defines

#define IW_ANGLE_2PI   ((iwangle)IW_GEOM_ONE)
#define IW_ANGLE_FROM_DEGREES(x)   ((iwangle)(((x) * IW_ANGLE_2PI) / 360.0))
#define IW_ANGLE_FROM_RADIANS(x)   ((iwangle)(((x) * IW_ANGLE_2PI) / (2 * PI)))
#define IW_ANGLE_MASK_PHASE(x)   ((iwangle)((x) & (IW_ANGLE_2PI - 1)))
#define IW_ANGLE_PI   ((iwangle)IW_GEOM_HALF)
#define IW_ANGLE_Q2PI   ((iwangle)IW_GEOM_QONE)
#define IW_ANGLE_TO_DEGREES(x)   ((int32)(((x) * 360 + (IW_ANGLE_2PI>>1)) / IW_ANGLE_2PI))
#define IW_ANGLE_TO_RADIANS(x)   ((float)(((x) * PI) / IW_ANGLE_PI))
#define IW_FIXED(x)   ((iwfixed)((x) * IW_GEOM_ONE))
#define IW_FIXED_FROM_FLOAT_SHIFTED(a, s)   ((iwfixed)((a) * (float)(1 << (s))))
#define IW_FIXED_TO_FLOAT(a)   ((float)(a) / (float)IW_GEOM_ONE)
#define IW_GEOM_ACOS   IwGeomACos
#define IW_GEOM_ASIN   IwGeomASin
#define IW_GEOM_ATAN2   IwGeomAtan2
#define IW_GEOM_COS   IwGeomCos
#define IW_GEOM_HALF   (1 << (IW_GEOM_POINT - 1))
#define IW_GEOM_ONE   (1 << IW_GEOM_POINT)
#define IW_GEOM_ONE2   (1 << (IW_GEOM_POINT << 1))
#define IW_GEOM_POINT   12
#define IW_GEOM_QACOS   IwGeomQACos
#define IW_GEOM_QASIN   IwGeomQASin
#define IW_GEOM_QATAN2   IwGeomQATan2
#define IW_GEOM_QCOS   IwGeomQCos
#define IW_GEOM_QEPSILON   0x200000
#define IW_GEOM_QHALF   (1 << (IW_GEOM_QPOINT - 1))
#define IW_GEOM_QONE   (1 << IW_GEOM_QPOINT)
#define IW_GEOM_QONE2   ((int64)1 << (IW_GEOM_QPOINT << 1))
#define IW_GEOM_QPOINT   30
#define IW_GEOM_QPOINT_TO_GEOM_POINT   (IW_GEOM_QPOINT - IW_GEOM_POINT)
#define IW_GEOM_QSIN   IwGeomQSin
#define IW_GEOM_ROUND(a)   (((a) + IW_GEOM_HALF) >> IW_GEOM_POINT)
#define IW_GEOM_SIN   IwGeomSin
#define IW_GEOM_TAN   IwGeomTan
#define IW_QFIXED(x)   ((iwqfixed)((x) * IW_GEOM_QONE))
#define IW_SFIXED(x)   ((iwsfixed)((x) * IW_GEOM_ONE))
#define IW_SFIXED_FROM_FLOAT(a)   IW_SFIXED_FROM_FIXED(IW_FIXED_FROM_FLOAT(a))
#define IW_UFIXED(x)   ((iwufixed)((x) * IW_GEOM_ONE))
#define IW_USFIXED(x)   ((iwusfixed)((x) * IW_GEOM_ONE))
#define PI   3.141592653589793f

Typedefs

typedef int32 iwangle
typedef int32 iwfixed
typedef int32 iwqangle
typedef int32 iwqfixed
typedef int16 iwsfixed
typedef uint32 iwufixed
typedef uint16 iwusfixed

Functions

double __cdecl acos (double)
double __cdecl asin (double)
double __cdecl atan2 (double, double)
double __cdecl cos (double)
INLINE iwangle IW_ANGLE_DIFFERENCE (iwangle x, iwangle y)
INLINE iwfixed IW_FIXED_DIV (iwfixed a, iwfixed b)
INLINE iwfixed IW_FIXED_DIV_SAFE (iwfixed a, iwfixed b)
INLINE iwfixed IW_FIXED_FROM_FLOAT (float a)
INLINE iwfixed IW_FIXED_FROM_FLOAT_CAST (float a)
INLINE iwfixed IW_FIXED_MUL (iwfixed a, iwfixed b)
INLINE iwfixed IW_FIXED_MUL2 (iwfixed a, iwfixed b, iwfixed d, iwfixed e)
INLINE iwfixed IW_FIXED_MUL2_SAFE (iwfixed a, iwfixed b, iwfixed d, iwfixed e)
INLINE iwfixed IW_FIXED_MUL3 (iwfixed a, iwfixed b, iwfixed c, iwfixed d, iwfixed e, iwfixed f)
INLINE iwfixed IW_FIXED_MUL3_SAFE (iwfixed a, iwfixed b, iwfixed c, iwfixed d, iwfixed e, iwfixed f)
INLINE iwfixed IW_FIXED_MUL_SAFE (iwfixed a, iwfixed b)
INLINE int32 IW_MUL64_3_SHIFT (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 shift)
INLINE int32 IW_MUL64_SHIFT (int32 a, int32 b, int32 shift)
INLINE int32 IW_MUL_2_SHIFT (int32 a, int32 b, int32 d, int32 e, int32 shift)
INLINE int32 IW_MUL_3_SHIFT (int32 a, int32 b, int32 c, int32 d, int32 e, int32 f, int32 shift)
S3E_END_C_DECL INLINE int32 IW_MULCHECK (const int32 a, const int32 b)
INLINE iwqfixed IW_QFIXED_MUL (iwqfixed a, iwqfixed b)
INLINE iwqfixed IW_QFIXED_MUL_SAFE (iwqfixed a, iwqfixed b)
INLINE iwsfixed IW_SFIXED_FROM_FIXED (iwfixed a)
INLINE iwsfixed IW_SFIXED_FROM_FLOAT_CAST (float a)
INLINE iwsfixed IW_SFIXED_MUL (iwfixed a, iwfixed b)
iwfixed IwGeomACos (iwfixed v)
iwfixed IwGeomASin (iwfixed v)
iwangle IwGeomAtan2 (int y, int x)
iwfixed IwGeomCos (iwangle x)
void IwGeomInit ()
iwqfixed IwGeomQACos (iwqfixed v)
iwqfixed IwGeomQASin (iwqfixed v)
iwqfixed IwGeomQATan2 (iwqfixed u, iwqfixed v)
iwqfixed IwGeomQCos (iwqangle x)
iwqfixed IwGeomQSin (iwqangle x)
S3E_BEGIN_C_DECL iwfixed IwGeomSin (iwangle x)
iwfixed IwGeomTan (iwangle x)
void IwGeomTerminate ()
double __cdecl sin (double)
double __cdecl sqrt (double)
double __cdecl tan (double)

Detailed Description

The IwGeomCore module is part of the IwGeom API and contains basic type definitions and mathematical operators.

Define Documentation

#define IW_ANGLE_2PI   ((iwangle)IW_GEOM_ONE)

(2 * PI) as an iwangle.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_FROM_DEGREES (  )     ((iwangle)(((x) * IW_ANGLE_2PI) / 360.0))

Converts an angle from degrees to iwangle.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_FROM_RADIANS (  )     ((iwangle)(((x) * IW_ANGLE_2PI) / (2 * PI)))

Converts an angle from radians to iwangle.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_MASK_PHASE (  )     ((iwangle)((x) & (IW_ANGLE_2PI - 1)))

Restricts an iwangle to the range 0 <= x < 2PI.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_PI   ((iwangle)IW_GEOM_HALF)

PI as an iwangle.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_Q2PI   ((iwangle)IW_GEOM_QONE)

(2 * PI) as an iwqangle.

Required Header Files
IwGeomCore.h

#define IW_ANGLE_TO_DEGREES (  )     ((int32)(((x) * 360 + (IW_ANGLE_2PI>>1)) / IW_ANGLE_2PI))

Converts an angle from iwangle to degrees.

Parameters:
x Angle stored as an iwangle.
Returns:
The angle as an integer, rounded to the nearest degree.
Required Header Files
IwGeomCore.h

#define IW_ANGLE_TO_RADIANS (  )     ((float)(((x) * PI) / IW_ANGLE_PI))

Converts an angle from iwangle to radians.

Required Header Files
IwGeomCore.h

#define IW_FIXED (  )     ((iwfixed)((x) * IW_GEOM_ONE))

Converts a value to a iwfixed value.

Required Header Files
IwGeomCore.h

#define IW_FIXED_FROM_FLOAT_SHIFTED ( a,
 )     ((iwfixed)((a) * (float)(1 << (s))))

Convert a floating point number to a fixed point number with s bits of precision.

Parameters:
a The floating point number to convert.
s The number of bits in the fractional part of the fixed point representation.
Required Header Files
IwGeomCore.h

#define IW_FIXED_TO_FLOAT (  )     ((float)(a) / (float)IW_GEOM_ONE)

Converts a 32 bit fixed point number to the nearest floating point number.

Parameters:
a The 32 bit fixed point number to convert.
Required Header Files
IwGeomCore.h

#define IW_GEOM_HALF   (1 << (IW_GEOM_POINT - 1))

One half (1/2) as a fixed point number for use with .12 formats.

#define IW_GEOM_ONE   (1 << IW_GEOM_POINT)

One as a fixed point number for use with .12 formats.

Required Header Files
IwGeomCore.h

#define IW_GEOM_ONE2   (1 << (IW_GEOM_POINT << 1))

Same value as IW_GEOM_ONE * IW_GEOM_ONE

Required Header Files
IwGeomCore.h

#define IW_GEOM_POINT   12

Default position of fixed point, used with iwfixed and iwsfixed.

Required Header Files
IwGeomCore.h

#define IW_GEOM_QEPSILON   0x200000

Small delta for high-resolution fixed point calculations.

Required Header Files
IwGeomCore.h

#define IW_GEOM_QHALF   (1 << (IW_GEOM_QPOINT - 1))

One half (1/2) as a fixed point number for use with .30 formats.

#define IW_GEOM_QONE   (1 << IW_GEOM_QPOINT)

One as a fixed point number for use with .30 formats.

Required Header Files
IwGeomCore.h

#define IW_GEOM_QONE2   ((int64)1 << (IW_GEOM_QPOINT << 1))

Same value as IW_GEOM_QONE * IW_GEOM_QONE

Required Header Files
IwGeomCore.h

#define IW_GEOM_QPOINT   30

Default position of fixed point, used with CIwQuat.

Required Header Files
IwGeomCore.h

#define IW_GEOM_QPOINT_TO_GEOM_POINT   (IW_GEOM_QPOINT - IW_GEOM_POINT)

Right shift used to convert quaternion fixed point to that of iwfixed.

Required Header Files
IwGeomCore.h

#define IW_GEOM_ROUND (  )     (((a) + IW_GEOM_HALF) >> IW_GEOM_POINT)

Rounds a 32 bit fixed point number to the nearest integer.

Required Header Files
IwGeomCore.h

#define IW_QFIXED (  )     ((iwqfixed)((x) * IW_GEOM_QONE))

Converts a value to an iwqfixed value.

Required Header Files
IwGeomCore.h

#define IW_SFIXED (  )     ((iwsfixed)((x) * IW_GEOM_ONE))

Converts a value to a iwsfixed value.

Required Header Files
IwGeomCore.h

#define IW_SFIXED_FROM_FLOAT (  )     IW_SFIXED_FROM_FIXED(IW_FIXED_FROM_FLOAT(a))

Convert a floating point number to the nearest 16 bit fixed point number.

Parameters:
a The floating point number to convert.
Required Header Files
IwGeomCore.h

#define IW_UFIXED (  )     ((iwufixed)((x) * IW_GEOM_ONE))

Converts a value to a iwufixed value.

Required Header Files
IwGeomCore.h

#define IW_USFIXED (  )     ((iwusfixed)((x) * IW_GEOM_ONE))

Converts a value to a iwusfixed value.

Required Header Files
IwGeomCore.h

#define PI   3.141592653589793f

Value of pi as a floating point number.

Required Header Files
IwGeomCore.h


Typedef Documentation

typedef int32 iwangle

Typedef of char fixed point number. Typedef of 32-bit fixed point angle, where 0x800 represents PI.

typedef int32 iwfixed

Typedef of signed 32-bit fixed point number, in 1.19.12 format.

typedef int32 iwqangle

Typedef of 32-bit fixed point angle, where 0x8000 represents PI.

typedef int32 iwqfixed

Typedef of signed 32-bit high-resolution fixed point number, in 1.1.30 format.

typedef int16 iwsfixed

Typedef of signed 16-bit fixed point number, in 1.3.12 format.

typedef uint32 iwufixed

Typedef of unsigned 32-bit fixed point number, in 0.20.12 format.

typedef uint16 iwusfixed

Typedef of unsigned 16-bit fixed point number, in 0.4.12 format.


Function Documentation

INLINE iwangle IW_ANGLE_DIFFERENCE ( iwangle  x,
iwangle  y 
)

Gets the difference between two angles in the range -IW_ANGLE_PI < (x - y) <= IW_ANGLE_PI.

Note:
The smaller of the two angles is chosen.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_DIV ( iwfixed  a,
iwfixed  b 
)

Divides two iwfixed numbers in fixed point.

Parameters:
a First long operand.
b Second long operand.
Returns:
Quotient of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_DIV_SAFE ( iwfixed  a,
iwfixed  b 
)

Divides two iwfixed numbers in fixed point, promoting the divident to a 64 bit number, if necessary.

Parameters:
a First long operand.
b Second long operand.
Returns:
Quotient of operands, correctly shifted.
Note:
This will run much slower than IW_FIXED_DIV if the absolute value of the dividend is larger than or equal to 1<<19.

Debug version provides overflow checking of the result.

Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_FROM_FLOAT ( float  a  ) 

Convert a floating point number to the nearest 32 bit fixed point number. Checks for overflows in debug builds.

Parameters:
a The floating point number to convert.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL ( iwfixed  a,
iwfixed  b 
)

Multiplies two iwfixed numbers in fixed point.

Parameters:
a First long operand.
b Second long operand.
Returns:
Product of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL2 ( iwfixed  a,
iwfixed  b,
iwfixed  d,
iwfixed  e 
)

Dot product of two two-coordinate, iwfixed vectors (a,b) and (d,e), in fixed point.

Parameters:
a,b First long fixed point vector.
d,e Second long fixed point vector.
Returns:
a*d + b*e correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL2_SAFE ( iwfixed  a,
iwfixed  b,
iwfixed  d,
iwfixed  e 
)

Dot product of two two-coordinate, iwfixed vectors (a,b) and (d,e), in fixed point. Calculations are made using int64 numbers.

Parameters:
a,b First long fixed point vector.
d,e Second long fixed point vector.
Returns:
a*d + b*e correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL3 ( iwfixed  a,
iwfixed  b,
iwfixed  c,
iwfixed  d,
iwfixed  e,
iwfixed  f 
)

Dot product of two three-coordinate, iwfixed vectors (a,b,c) and (d,e,f), in fixed point.

Parameters:
a,b,c First long fixed point vector.
d,e,f Second long fixed point vector.
Returns:
a*d + b*e + c*f correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL3_SAFE ( iwfixed  a,
iwfixed  b,
iwfixed  c,
iwfixed  d,
iwfixed  e,
iwfixed  f 
)

Dot product of two three-coordinate, iwfixed vectors (a,b,c) and (d,e,f), in fixed point. Calculations are made using int64 numbers.

Parameters:
a,b,c First long fixed point vector.
d,e,f Second long fixed point vector.
Returns:
a*d + b*e + c*f correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwfixed IW_FIXED_MUL_SAFE ( iwfixed  a,
iwfixed  b 
)

Multiplies two iwfixed numbers, in fixed point, using int64 numbers.

Parameters:
a First long operand.
b Second long operand.
Returns:
Product of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE int32 IW_MUL64_3_SHIFT ( int32  a,
int32  b,
int32  c,
int32  d,
int32  e,
int32  f,
int32  shift 
)

Dot product of two three-coordinate, int32 vectors (a,b,c) and (d,e,f), in fixed point. Accumulates in 64bit with a specified shift down

Parameters:
a,b,c First long fixed point vector.
d,e,f Second long fixed point vector.
Returns:
a*d + b*e + c*f shifted accordingly.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE int32 IW_MUL64_SHIFT ( int32  a,
int32  b,
int32  shift 
)

Multiply two int32 values Accumulates in 64bit with a specified shift down

Parameters:
a First long fixed point value.
b Second long fixed point value.
Returns:
a*b shifted accordingly.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE int32 IW_MUL_2_SHIFT ( int32  a,
int32  b,
int32  d,
int32  e,
int32  shift 
)

Dot product of two two-coordinate, int32 vectors (a,b) and (d,e), in fixed point.

Parameters:
a,b First long fixed point vector.
d,e Second long fixed point vector.
shift Amount to shift down by
Returns:
a*d + b*e shifted accordingly.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE int32 IW_MUL_3_SHIFT ( int32  a,
int32  b,
int32  c,
int32  d,
int32  e,
int32  f,
int32  shift 
)

Dot product of two three-coordinate, int32 vectors (a,b,c) and (d,e,f), in fixed point.

Parameters:
a,b,c First long fixed point vector.
d,e,f Second long fixed point vector.
shift Amount to shift down by
Returns:
a*d + b*e + c*f shifted accordingly.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

S3E_END_C_DECL INLINE int32 IW_MULCHECK ( const int32  a,
const int32  b 
)

Multiplies two 32 bit integers, asserting if there is overflow

INLINE iwqfixed IW_QFIXED_MUL ( iwqfixed  a,
iwqfixed  b 
)

Multiplies two iwqfixed numbers in fixed point.

Parameters:
a First long operand.
b Second long operand.
Returns:
Product of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwqfixed IW_QFIXED_MUL_SAFE ( iwqfixed  a,
iwqfixed  b 
)

Multiplies two iwqfixed numbers, in fixed point, using int64 numbers.

Parameters:
a First long operand.
b Second long operand.
Returns:
Product of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

INLINE iwsfixed IW_SFIXED_FROM_FIXED ( iwfixed  a  ) 

Converts a iwfixed value to a iwsfixed value. Checks for overflows in debug builds.

Required Header Files
IwGeomCore.h

INLINE iwsfixed IW_SFIXED_MUL ( iwfixed  a,
iwfixed  b 
)

Multiplies two iwfixed numbers, in fixed point, casting the result to iwsfixed. Debug includes a test that the result will fit in an iwsfixed

Parameters:
a First long operand.
b Second long operand.
Returns:
Product of operands, correctly shifted.
Note:
Debug version provides overflow checking.
Required Header Files
IwGeomCore.h

iwfixed IwGeomACos ( iwfixed  v  ) 

acos function for iwfixed

Required Header Files
IwGeomCore.h

iwfixed IwGeomASin ( iwfixed  v  ) 

asin function for iwfixed

Required Header Files
IwGeomCore.h

iwangle IwGeomAtan2 ( int  y,
int  x 
)

If we consider a standard graph with +ve x to the right, +ve y up, and theta measured anticlockwise from +ve x, this returns the angle in the range 0..0xfff

Parameters:
y sin
x cos
Returns:
Anticlockwise angle vector (x,y) makes with the X-axis.
Required Header Files
IwGeomCore.h

iwfixed IwGeomCos ( iwangle  x  ) 

cos function for fixed point angle.

Required Header Files
IwGeomCore.h

void IwGeomInit (  ) 

Initialises the IwGeom module.

Note:
This is done automatically by IwGxInit().
Required Header Files
IwGeomCore.h

iwqfixed IwGeomQACos ( iwqfixed  v  ) 

acos function for iwqfixed

Required Header Files
IwGeomCore.h

iwqfixed IwGeomQASin ( iwqfixed  v  ) 

asin function for iwqfixed

Required Header Files
IwGeomCore.h

iwqfixed IwGeomQATan2 ( iwqfixed  u,
iwqfixed  v 
)

atan2 function for iwqfixed

Required Header Files
IwGeomCore.h

iwqfixed IwGeomQCos ( iwqangle  x  ) 

cos function for iwqfixed angle.

Required Header Files
IwGeomCore.h

iwqfixed IwGeomQSin ( iwqangle  x  ) 

sin function for iwqfixed angle.

Required Header Files
IwGeomCore.h

S3E_BEGIN_C_DECL iwfixed IwGeomSin ( iwangle  x  ) 

sin function for fixed point angle.

Required Header Files
IwGeomCore.h

iwfixed IwGeomTan ( iwangle  x  ) 

tan function for fixed point angle.

Required Header Files
IwGeomCore.h

void IwGeomTerminate (  ) 

Terminate IwGeom module. This is done automatically by IwGxTerminate().

Required Header Files
IwGeomCore.h