Bullet Collision Detection & Physics Library
Classes | Macros | Typedefs | Functions
btScalar.h File Reference
#include <math.h>
#include <stdlib.h>
#include <float.h>
Include dependency graph for btScalar.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  btTypedObject
 rudimentary class to provide type info More...
 

Macros

#define BT_BULLET_VERSION   281
 
#define SIMD_FORCE_INLINE   __forceinline
 
#define ATTRIBUTE_ALIGNED16(a)   __declspec(align(16)) a
 
#define ATTRIBUTE_ALIGNED64(a)   __declspec(align(64)) a
 
#define ATTRIBUTE_ALIGNED128(a)   __declspec (align(128)) a
 
#define btAssert(x)
 
#define btFullAssert(x)
 
#define btLikely(_c)   _c
 
#define btUnlikely(_c)   _c
 
#define BT_LARGE_FLOAT   1e18f
 
#define BT_DECLARE_ALIGNED_ALLOCATOR()
 
#define SIMD_2_PI   btScalar(6.283185307179586232)
 
#define SIMD_PI   (SIMD_2_PI * btScalar(0.5))
 
#define SIMD_HALF_PI   (SIMD_2_PI * btScalar(0.25))
 
#define SIMD_RADS_PER_DEG   (SIMD_2_PI / btScalar(360.0))
 
#define SIMD_DEGS_PER_RAD   (btScalar(360.0) / SIMD_2_PI)
 
#define SIMDSQRT12   btScalar(0.7071067811865475244008443621048490)
 
#define btRecipSqrt(x)   ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */
 
#define SIMD_EPSILON   FLT_EPSILON
 
#define SIMD_INFINITY   FLT_MAX
 
#define BT_DECLARE_HANDLE(name)   typedef struct name##__ { int unused; } *name
 
#define btFsels(a, b, c)   (btScalar)btFsel(a,b,c)
 

Typedefs

typedef float btScalar
 The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision. More...
 

Functions

int btGetVersion ()
 
btScalar btSqrt (btScalar y)
 
btScalar btFabs (btScalar x)
 
btScalar btCos (btScalar x)
 
btScalar btSin (btScalar x)
 
btScalar btTan (btScalar x)
 
btScalar btAcos (btScalar x)
 
btScalar btAsin (btScalar x)
 
btScalar btAtan (btScalar x)
 
btScalar btAtan2 (btScalar x, btScalar y)
 
btScalar btExp (btScalar x)
 
btScalar btLog (btScalar x)
 
btScalar btPow (btScalar x, btScalar y)
 
btScalar btFmod (btScalar x, btScalar y)
 
btScalar btAtan2Fast (btScalar y, btScalar x)
 
bool btFuzzyZero (btScalar x)
 
bool btEqual (btScalar a, btScalar eps)
 
bool btGreaterEqual (btScalar a, btScalar eps)
 
int btIsNegative (btScalar x)
 
btScalar btRadians (btScalar x)
 
btScalar btDegrees (btScalar x)
 
btScalar btFsel (btScalar a, btScalar b, btScalar c)
 
bool btMachineIsLittleEndian ()
 
unsigned btSelect (unsigned condition, unsigned valueIfConditionNonZero, unsigned valueIfConditionZero)
 btSelect avoids branches, which makes performance much better for consoles like Playstation 3 and XBox 360 Thanks Phil Knight. More...
 
int btSelect (unsigned condition, int valueIfConditionNonZero, int valueIfConditionZero)
 
float btSelect (unsigned condition, float valueIfConditionNonZero, float valueIfConditionZero)
 
template<typename T >
void btSwap (T &a, T &b)
 
unsigned btSwapEndian (unsigned val)
 
unsigned short btSwapEndian (unsigned short val)
 
unsigned btSwapEndian (int val)
 
unsigned short btSwapEndian (short val)
 
unsigned int btSwapEndianFloat (float d)
 btSwapFloat uses using char pointers to swap the endianness More...
 
float btUnswapEndianFloat (unsigned int a)
 
void btSwapEndianDouble (double d, unsigned char *dst)
 
double btUnswapEndianDouble (const unsigned char *src)
 
btScalar btNormalizeAngle (btScalar angleInRadians)
 
template<typename T >
T * btAlignPointer (T *unalignedPtr, size_t alignment)
 align a pointer to the provided alignment, upwards More...
 

Macro Definition Documentation

#define ATTRIBUTE_ALIGNED128 (   a)    __declspec (align(128)) a

Definition at line 61 of file btScalar.h.

#define ATTRIBUTE_ALIGNED16 (   a)    __declspec(align(16)) a

Definition at line 59 of file btScalar.h.

#define ATTRIBUTE_ALIGNED64 (   a)    __declspec(align(64)) a

Definition at line 60 of file btScalar.h.

#define BT_BULLET_VERSION   281

Definition at line 31 of file btScalar.h.

#define BT_DECLARE_ALIGNED_ALLOCATOR ( )
Value:
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
SIMD_FORCE_INLINE void* operator new[](size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
SIMD_FORCE_INLINE void operator delete[](void* ptr) { btAlignedFree(ptr); } \
SIMD_FORCE_INLINE void* operator new[](size_t, void* ptr) { return ptr; } \
SIMD_FORCE_INLINE void operator delete[](void*, void*) { } \

Definition at line 335 of file btScalar.h.

#define BT_DECLARE_HANDLE (   name)    typedef struct name##__ { int unused; } *name

Definition at line 463 of file btScalar.h.

#define BT_LARGE_FLOAT   1e18f

Definition at line 266 of file btScalar.h.

#define btAssert (   x)

Definition at line 101 of file btScalar.h.

#define btFsels (   a,
  b,
 
)    (btScalar)btFsel(a,b,c)

Definition at line 471 of file btScalar.h.

#define btFullAssert (   x)

Definition at line 104 of file btScalar.h.

#define btLikely (   _c)    _c

Definition at line 106 of file btScalar.h.

#define btRecipSqrt (   x)    ((btScalar)(btScalar(1.0)/btSqrt(btScalar(x)))) /* reciprocal square root */

Definition at line 419 of file btScalar.h.

#define btUnlikely (   _c)    _c

Definition at line 107 of file btScalar.h.

#define SIMD_2_PI   btScalar(6.283185307179586232)

Definition at line 412 of file btScalar.h.

#define SIMD_DEGS_PER_RAD   (btScalar(360.0) / SIMD_2_PI)

Definition at line 416 of file btScalar.h.

#define SIMD_EPSILON   FLT_EPSILON

Definition at line 426 of file btScalar.h.

#define SIMD_FORCE_INLINE   __forceinline

Definition at line 58 of file btScalar.h.

#define SIMD_HALF_PI   (SIMD_2_PI * btScalar(0.25))

Definition at line 414 of file btScalar.h.

#define SIMD_INFINITY   FLT_MAX

Definition at line 427 of file btScalar.h.

#define SIMD_PI   (SIMD_2_PI * btScalar(0.5))

Definition at line 413 of file btScalar.h.

#define SIMD_RADS_PER_DEG   (SIMD_2_PI / btScalar(360.0))

Definition at line 415 of file btScalar.h.

#define SIMDSQRT12   btScalar(0.7071067811865475244008443621048490)

Definition at line 417 of file btScalar.h.

Typedef Documentation

typedef float btScalar

The btScalar type abstracts floating point numbers, to easily switch between double and single floating point precision.

Definition at line 264 of file btScalar.h.

Function Documentation

btScalar btAcos ( btScalar  x)
inline

Definition at line 389 of file btScalar.h.

template<typename T >
T* btAlignPointer ( T *  unalignedPtr,
size_t  alignment 
)

align a pointer to the provided alignment, upwards

Definition at line 646 of file btScalar.h.

btScalar btAsin ( btScalar  x)
inline

Definition at line 396 of file btScalar.h.

btScalar btAtan ( btScalar  x)
inline

Definition at line 403 of file btScalar.h.

btScalar btAtan2 ( btScalar  x,
btScalar  y 
)
inline

Definition at line 404 of file btScalar.h.

btScalar btAtan2Fast ( btScalar  y,
btScalar  x 
)
inline

Definition at line 430 of file btScalar.h.

btScalar btCos ( btScalar  x)
inline

Definition at line 386 of file btScalar.h.

btScalar btDegrees ( btScalar  x)
inline

Definition at line 461 of file btScalar.h.

bool btEqual ( btScalar  a,
btScalar  eps 
)
inline

Definition at line 448 of file btScalar.h.

btScalar btExp ( btScalar  x)
inline

Definition at line 405 of file btScalar.h.

btScalar btFabs ( btScalar  x)
inline

Definition at line 385 of file btScalar.h.

btScalar btFmod ( btScalar  x,
btScalar  y 
)
inline

Definition at line 408 of file btScalar.h.

btScalar btFsel ( btScalar  a,
btScalar  b,
btScalar  c 
)
inline

Definition at line 466 of file btScalar.h.

bool btFuzzyZero ( btScalar  x)
inline

Definition at line 446 of file btScalar.h.

int btGetVersion ( )
inline

Definition at line 33 of file btScalar.h.

bool btGreaterEqual ( btScalar  a,
btScalar  eps 
)
inline

Definition at line 451 of file btScalar.h.

int btIsNegative ( btScalar  x)
inline

Definition at line 456 of file btScalar.h.

btScalar btLog ( btScalar  x)
inline

Definition at line 406 of file btScalar.h.

bool btMachineIsLittleEndian ( )
inline

Definition at line 474 of file btScalar.h.

btScalar btNormalizeAngle ( btScalar  angleInRadians)
inline

Definition at line 612 of file btScalar.h.

btScalar btPow ( btScalar  x,
btScalar  y 
)
inline

Definition at line 407 of file btScalar.h.

btScalar btRadians ( btScalar  x)
inline

Definition at line 460 of file btScalar.h.

unsigned btSelect ( unsigned  condition,
unsigned  valueIfConditionNonZero,
unsigned  valueIfConditionZero 
)
inline

btSelect 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

Definition at line 488 of file btScalar.h.

int btSelect ( unsigned  condition,
int  valueIfConditionNonZero,
int  valueIfConditionZero 
)
inline

Definition at line 498 of file btScalar.h.

float btSelect ( unsigned  condition,
float  valueIfConditionNonZero,
float  valueIfConditionZero 
)
inline

Definition at line 504 of file btScalar.h.

btScalar btSin ( btScalar  x)
inline

Definition at line 387 of file btScalar.h.

btScalar btSqrt ( btScalar  y)
inline

Definition at line 365 of file btScalar.h.

template<typename T >
void btSwap ( T &  a,
T &  b 
)
inline

Definition at line 513 of file btScalar.h.

unsigned btSwapEndian ( unsigned  val)
inline

Definition at line 522 of file btScalar.h.

unsigned short btSwapEndian ( unsigned short  val)
inline

Definition at line 527 of file btScalar.h.

unsigned btSwapEndian ( int  val)
inline

Definition at line 532 of file btScalar.h.

unsigned short btSwapEndian ( short  val)
inline

Definition at line 537 of file btScalar.h.

void btSwapEndianDouble ( double  d,
unsigned char *  dst 
)
inline

Definition at line 578 of file btScalar.h.

unsigned int btSwapEndianFloat ( float  d)
inline

btSwapFloat uses using char pointers to swap the endianness

btSwapFloat/btSwapDouble 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

Definition at line 548 of file btScalar.h.

btScalar btTan ( btScalar  x)
inline

Definition at line 388 of file btScalar.h.

double btUnswapEndianDouble ( const unsigned char *  src)
inline

Definition at line 594 of file btScalar.h.

float btUnswapEndianFloat ( unsigned int  a)
inline

Definition at line 562 of file btScalar.h.