Fixed-point math functions.
[Fixed-point.]


Defines

#define XY_mult(a, b)
 Multiply two XY_fixed values.
#define XY_qdiv(a, b)
 Divide one XY_fixed value by another.
#define XY_div(a, b)
 Divide one XY_fixed value by another.
#define XY_FIXED_DIV_ZERO   ((1 << XY_FIXED_SHIFT_HALF) - 1)
 The maximum value that, when XY_div() is used to divide two digits, the denominator may be, and be considered zero (due to shifting to reduce precision loss.
#define XY_fpart(a)   ((a) & (XY_FIXED_ONE - 1))
 Return the fractional part of 'a'.
#define XY_rfpart(a)   (XY_FIXED_ONE - XY_fpart(a))
 Return one minus the fractional part of 'a'.
#define XY_ipart(a)   ((a) - XY_fpart(a))
 Returns the integer (whole) part of 'a'.
#define XY_round(a)   (XY_ipart((a) + (1 << (XY_FIXED_SHIFT - 1))))
 Rounds 'a' up to the nearest integer (whole).
#define XY_sin(degrees)   (XY_cos(90 - (degrees)))
 Returns sine() of 'degrees'.

Functions

XY_fixed XY_cos (int degrees)
 Returns cosine() of 'degrees'.

Define Documentation

#define XY_mult ( a,
 ) 

Value:

(((a) >> XY_FIXED_SHIFT_HALF) * \
                      ((b) >> XY_FIXED_SHIFT_HALF))
Multiply two XY_fixed values.

Parameters:
a multiplicand
b multiplicand
Returns:
a multiplied by b, approximately

#define XY_qdiv ( a,
 ) 

Value:

(((a) / \
                       ((b) >> XY_FIXED_SHIFT_HALF)) \
                      << XY_FIXED_SHIFT_HALF)
Divide one XY_fixed value by another.

Parameters:
a numerator
b denominator
Returns:
a divided by b, approximately.

#define XY_div ( a,
 ) 

Value:

(((b) >> XY_FIXED_SHIFT_HALF) == 0 ? \
                     XY_FIXED_NAN : XY_qdiv((a),(b)))
Divide one XY_fixed value by another.

Returns Not-A-Number if denominator is (sufficient close to) zero.

Parameters:
a numerator
b denominator
Returns:
a divided by b, approximately, or XY_FIXED_NAN if b is zero (approximately)

#define XY_FIXED_DIV_ZERO   ((1 << XY_FIXED_SHIFT_HALF) - 1)

The maximum value that, when XY_div() is used to divide two digits, the denominator may be, and be considered zero (due to shifting to reduce precision loss.

)

#define XY_fpart (  )     ((a) & (XY_FIXED_ONE - 1))

Return the fractional part of 'a'.

#define XY_rfpart (  )     (XY_FIXED_ONE - XY_fpart(a))

Return one minus the fractional part of 'a'.

#define XY_ipart (  )     ((a) - XY_fpart(a))

Returns the integer (whole) part of 'a'.

#define XY_round (  )     (XY_ipart((a) + (1 << (XY_FIXED_SHIFT - 1))))

Rounds 'a' up to the nearest integer (whole).

#define XY_sin ( degrees   )     (XY_cos(90 - (degrees)))

Returns sine() of 'degrees'.

('degrees' is a non-fixed-point value, in degrees. Values outside 0-359 are accounted for.)

Parameters:
degrees is an angle, in degrees (between 0 and 359).
Returns:
sine() of the angle, in XY_fixed.


Function Documentation

XY_fixed XY_cos ( int  degrees  ) 

Returns cosine() of 'degrees'.

('degrees' is a non-fixed-point value, in degrees. Values outside 0-359 are accounted for.)

Parameters:
degrees is an angle, in degrees (between 0 and 359).
Returns:
cosine() of the angle, in XY_fixed.


Generated on Sat Aug 16 22:15:09 2008 for libcrtxy by  doxygen 1.5.5