#include <math.h>
#include <stdlib.h>
#include <cstdlib>
#include <cfloat>
#include <float.h>
#include <assert.h>
Go to the source code of this file.
Classes | |
struct | tf2TypedObject |
rudimentary class to provide type info More... | |
Macros | |
#define | ATTRIBUTE_ALIGNED128(a) a |
#define | ATTRIBUTE_ALIGNED16(a) a |
#define | ATTRIBUTE_ALIGNED64(a) a |
#define | TF2_DECLARE_ALIGNED_ALLOCATOR() |
#define | TF2_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name |
#define | TF2_LARGE_FLOAT 1e30 |
#define | tf2Assert(x) |
#define | tf2Fsels(a, b, c) (tf2Scalar)tf2Fsel(a,b,c) |
#define | tf2FullAssert(x) |
#define | tf2Likely(_c) _c |
#define | tf2RecipSqrt(x) ((tf2Scalar)(tf2Scalar(1.0)/tf2Sqrt(tf2Scalar(x)))) /* reciprocal square root */ |
#define | TF2SIMD_2_PI tf2Scalar(6.283185307179586232) |
#define | TF2SIMD_DEGS_PER_RAD (tf2Scalar(360.0) / TF2SIMD_2_PI) |
#define | TF2SIMD_EPSILON DBL_EPSILON |
#define | TF2SIMD_FORCE_INLINE inline |
#define | TF2SIMD_HALF_PI (TF2SIMD_2_PI * tf2Scalar(0.25)) |
#define | TF2SIMD_INFINITY DBL_MAX |
#define | TF2SIMD_PI (TF2SIMD_2_PI * tf2Scalar(0.5)) |
#define | TF2SIMD_RADS_PER_DEG (TF2SIMD_2_PI / tf2Scalar(360.0)) |
#define | TF2SIMDSQRT12 tf2Scalar(0.7071067811865475244008443621048490) |
#define | tf2Unlikely(_c) _c |
Typedefs | |
typedef double | tf2Scalar |
The tf2Scalar type abstracts floating point numbers, to easily switch between double and single floating point precision. More... | |
#define ATTRIBUTE_ALIGNED16 | ( | a | ) | a |
#define TF2_DECLARE_ALIGNED_ALLOCATOR | ( | ) |
#define TF2_DECLARE_HANDLE | ( | name | ) | typedef struct name##__ { int unused; } *name |
#define TF2SIMD_DEGS_PER_RAD (tf2Scalar(360.0) / TF2SIMD_2_PI) |
#define TF2SIMD_HALF_PI (TF2SIMD_2_PI * tf2Scalar(0.25)) |
#define TF2SIMD_PI (TF2SIMD_2_PI * tf2Scalar(0.5)) |
#define TF2SIMD_RADS_PER_DEG (TF2SIMD_2_PI / tf2Scalar(360.0)) |
#define TF2SIMDSQRT12 tf2Scalar(0.7071067811865475244008443621048490) |
typedef double tf2Scalar |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Acos | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Asin | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Atan | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Atan2 | ( | tf2Scalar | x, |
tf2Scalar | y | ||
) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Atan2Fast | ( | tf2Scalar | y, |
tf2Scalar | x | ||
) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Cos | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Degrees | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE bool tf2Equal | ( | tf2Scalar | a, |
tf2Scalar | eps | ||
) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Exp | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Fabs | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Fmod | ( | tf2Scalar | x, |
tf2Scalar | y | ||
) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Fsel | ( | tf2Scalar | a, |
tf2Scalar | b, | ||
tf2Scalar | c | ||
) |
TF2SIMD_FORCE_INLINE bool tf2FuzzyZero | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE bool tf2GreaterEqual | ( | tf2Scalar | a, |
tf2Scalar | eps | ||
) |
TF2SIMD_FORCE_INLINE int tf2IsNegative | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Log | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE bool tf2MachineIsLittleEndian | ( | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2NormalizeAngle | ( | tf2Scalar | angleInRadians | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Pow | ( | tf2Scalar | x, |
tf2Scalar | y | ||
) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Radians | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE float tf2Select | ( | unsigned | condition, |
float | valueIfConditionNonZero, | ||
float | valueIfConditionZero | ||
) |
TF2SIMD_FORCE_INLINE int tf2Select | ( | unsigned | condition, |
int | valueIfConditionNonZero, | ||
int | valueIfConditionZero | ||
) |
TF2SIMD_FORCE_INLINE unsigned tf2Select | ( | unsigned | condition, |
unsigned | valueIfConditionNonZero, | ||
unsigned | valueIfConditionZero | ||
) |
tf2Select avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 Thanks Phil Knight. See also http://www.cellperformance.com/articles/2006/04/more_techniques_for_eliminatin_1.html
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sin | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE tf2Scalar tf2Sqrt | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE void tf2Swap | ( | T & | a, |
T & | b | ||
) |
TF2SIMD_FORCE_INLINE unsigned tf2SwapEndian | ( | int | val | ) |
TF2SIMD_FORCE_INLINE unsigned short tf2SwapEndian | ( | short | val | ) |
TF2SIMD_FORCE_INLINE unsigned short tf2SwapEndian | ( | unsigned short | val | ) |
TF2SIMD_FORCE_INLINE unsigned tf2SwapEndian | ( | unsigned | val | ) |
TF2SIMD_FORCE_INLINE void tf2SwapEndianDouble | ( | double | d, |
unsigned char * | dst | ||
) |
TF2SIMD_FORCE_INLINE unsigned int tf2SwapEndianFloat | ( | float | d | ) |
tf2SwapFloat uses using char pointers to swap the endianness
tf2SwapFloat/tf2SwapDouble will NOT return a float, because the machine might 'correct' invalid floating point values Not all values of sign/exponent/mantissa are valid floating point numbers according to IEEE 754. When a floating point unit is faced with an invalid value, it may actually change the value, or worse, throw an exception. In most systems, running user mode code, you wouldn't get an exception, but instead the hardware/os/runtime will 'fix' the number for you. so instead of returning a float/double, we return integer/long long integer
TF2SIMD_FORCE_INLINE tf2Scalar tf2Tan | ( | tf2Scalar | x | ) |
TF2SIMD_FORCE_INLINE double tf2UnswapEndianDouble | ( | const unsigned char * | src | ) |
TF2SIMD_FORCE_INLINE float tf2UnswapEndianFloat | ( | unsigned int | a | ) |