QSDK 1.1 Documentation
Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

Miscellaneous
[QMaths]


Functions

float modff (float f, float *iPart)
 Split a floating point value into its integer and fractional parts.

float sincosf (float &rcos, float theta)
 Calculate both sine and cosine of an angle.

double sincos (double &rcos, double theta)
 Calculate both sine and cosine of an angle.

int floatToFixed (float f, unsigned int prec)
 Convert a floating point value to fixed point.

int floatToFixed (float f)
 Convert a floating point value to fixed point with eight bits of precision.

float fixedToFloat (int i, unsigned int prec)
 Convert a fixed point value to floating point.

float fixedToFloat (int i)
 Convert an eight bit fixed point value to floating point.

int floatToSign (float f)
 Extract the sign bit of a floating point value.

int floatToMask (float f)
 Extract the sign bit of a floating point value.

int intToMask (int i)
 Extract the sign bit of an integer value.

int floatToIntBits (float f)
 Extract the underlying binary representation of a floating point value.

float intBitsToFloat (int i)
 Reconstitute a floating point value given its underlying binary representation.

bool floatIsNegative (float f)
 Compare a floating point value to zero.

bool floatIsPositive (float f)
 Compare a floating point value to zero.

bool floatIsZero (float f)
 Compare a floating point value to zero.

bool equals (float a, float b, float e=Epsilon)
 Compare two floating point values.

bool lessThan (float a, float b, float e=Epsilon)
 Compare two floating point values.

bool greaterThan (float a, float b, float e=Epsilon)
 Compare two floating point values.

int lessEqual (float a, float b, float e=Epsilon)
 Compare two floating point values.

bool greaterEqual (float a, float b, float e=Epsilon)
 Compare two floating point values.

int compare (float a, float b, float e=Epsilon)
 Compare two floating point values.

float conditional (float a, float b, float ans1, float ans2)
 Compare two floating point values.

float maximum (float a, float b)
 Compare two floating point values.

float minimum (float a, float b)
 Compare two floating point values.

template<class T> T conditional (T a, T b, T ans1, T ans2)
 Compare two values.

template<class T> T maximum (T a, T b)
 Compare two values.

template<class T> T minimum (T a, T b)
 Compare two values.

template<class T> T clamp (T val, T min, T max)
 Clamp a value to a range.

float interpolate (float mul, float f1, float f2)
 Interpolate between two floating point values.


Variables

const float Epsilon = 0.001f
const float PI = 3.1415926536f

Function Documentation

template<class T>
T clamp val,
min,
max
 

Clamp a value to a range.

Return values:
min if val is less than min
max if val is greater than max
val otherwise

int compare float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
zero if the absolute difference between a and b is less than e
1 if a is more than e greater than b
-1 if a is more than e less than b

template<class T>
T conditional a,
b,
ans1,
ans2
 

Compare two values.

Return values:
ans1 if a is less than b
ans2 otherwise

float conditional float  a,
float  b,
float  ans1,
float  ans2
[inline]
 

Compare two floating point values.

Return values:
ans1 if a is less than b
ans2 otherwise

bool equals float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
true if the absolute difference between a and b is less than e
false otherwise

float fixedToFloat int  i  )  [inline]
 

Convert an eight bit fixed point value to floating point.

Parameters:
i The fixed point value to convert
Returns:
A floating point representation of i

float fixedToFloat int  i,
unsigned int  prec
[inline]
 

Convert a fixed point value to floating point.

Parameters:
i The fixed point value to convert
prec The number of binary digits of precision used in the fixed point value i
Returns:
A floating point representation of i

bool floatIsNegative float  f  )  [inline]
 

Compare a floating point value to zero.

Parameters:
f A floating point value
Return values:
true if f is negative
false otherwise

bool floatIsPositive float  f  )  [inline]
 

Compare a floating point value to zero.

Parameters:
f A floating point value
Return values:
true if f is positive
false otherwise

bool floatIsZero float  f  )  [inline]
 

Compare a floating point value to zero.

Parameters:
f A floating point value
Return values:
true if f is zero
false otherwise

int floatToFixed float  f  )  [inline]
 

Convert a floating point value to fixed point with eight bits of precision.

Parameters:
f The floating point value to convert
Returns:
A fixed point representation of f

int floatToFixed float  f,
unsigned int  prec
[inline]
 

Convert a floating point value to fixed point.

Parameters:
f The floating point value to convert
prec The number of binary digits of precision required for the fixed point representation of f
Returns:
A fixed point representation of f

int floatToIntBits float  f  )  [inline]
 

Extract the underlying binary representation of a floating point value.

Parameters:
f A floating point value

int floatToMask float  f  )  [inline]
 

Extract the sign bit of a floating point value.

Parameters:
f A floating point value
Return values:
~0 if f is negative
zero otherwise

int floatToSign float  f  )  [inline]
 

Extract the sign bit of a floating point value.

Parameters:
f A floating point value
Return values:
one if f is negative
zero otherwise

bool greaterEqual float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
true if a is more than e greater than b or if the absolute difference between a and b is less than e
false otherwise

bool greaterThan float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
true if a is more than e greater than b
false otherwise

float intBitsToFloat int  i  )  [inline]
 

Reconstitute a floating point value given its underlying binary representation.

Parameters:
i The ieee binary representation of a floating point value

float interpolate float  mul,
float  f1,
float  f2
[inline, static]
 

Interpolate between two floating point values.

Returns:
f1 + (f2 - f1) * mul

int intToMask int  i  )  [inline]
 

Extract the sign bit of an integer value.

Parameters:
i A integer value
Return values:
~0 if f is negative
zero otherwise

int lessEqual float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
true if a is more than e less than b or if the absolute difference between a and b is less than e
false otherwise

bool lessThan float  a,
float  b,
float  e = Epsilon
[inline]
 

Compare two floating point values.

Parameters:
a A floating point value
b A floating point value
e Requested error bound
Return values:
true if a is more than e less than b
false otherwise

template<class T>
T maximum a,
b
 

Compare two values.

Return values:
a if a is greater than b
b otherwise

float maximum float  a,
float  b
[inline]
 

Compare two floating point values.

Return values:
a if a is greater than b
b otherwise

template<class T>
T minimum a,
b
 

Compare two values.

Return values:
a if a is less than b
b otherwise

float minimum float  a,
float  b
[inline]
 

Compare two floating point values.

Return values:
a if a is less than b
b otherwise

float modff float  f,
float *  iPart
 

Split a floating point value into its integer and fractional parts.

Parameters:
f The floating point value being decomposed
iPart The address of a variable which will receive the integer part of f
Returns:
The fractional part of f.

double sincos double &  rcos,
double  theta
[inline]
 

Calculate both sine and cosine of an angle.

Parameters:
rcos The address of a variable which will receive the cosine of theta
theta An angle in radians
Returns:
The sine of theta

float sincosf float &  rcos,
float  theta
[inline]
 

Calculate both sine and cosine of an angle.

Parameters:
rcos The address of a variable which will receive the cosine of theta
theta An angle in radians
Returns:
The sine of theta


Variable Documentation

const float Maths::Epsilon = 0.001f [static]
 

Standard error bound.

const float Maths::PI = 3.1415926536f [static]
 

PI

Return to QSDK documentation Contents page. Contact details for support, information and fault-reporting.
Qube Software Limited © 2000-2004