Bullet Collision Detection & Physics Library: gim_math.h File Reference

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

Macros | Enumerations | Functions
gim_math.h File Reference
`#include "LinearMath/btScalar.h"`
Include dependency graph for gim_math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros
#define | GREAL btScalar
#define | GREAL2 double
#define | GINT int
#define | GUINT unsigned int
#define | GSHORT short
#define | GUSHORT unsigned short
#define | GINT64 long long
#define | GUINT64 unsigned long long
#define | G_PI 3.14159265358979f
#define | G_HALF_PI 1.5707963f
#define | G_TWO_PI 6.28318530f
#define | G_ROOT3 1.73205f
#define | G_ROOT2 1.41421f
#define | G_UINT_INFINITY 0xffffffff
| A very very high value.
#define | G_REAL_INFINITY FLT_MAX
#define | G_SIGN_BITMASK 0x80000000
#define | G_EPSILON SIMD_EPSILON
#define | G_DEGTORAD(X) ((X)*3.1415926f / 180.0f)
#define | G_RADTODEG(X) ((X)*180.0f / 3.1415926f)
#define | GIM_IR(x) ((GUINT&)(x))
| Integer representation of a floating-point value.
#define | GIM_SIR(x) ((GINT&)(x))
| Signed integer representation of a floating-point value.
#define | GIM_AIR(x) (GIM_IR(x) & 0x7fffffff)
| Absolute integer representation of a floating-point value.
#define | GIM_FR(x) ((GREAL&)(x))
| Floating-point representation of an integer value.
#define | GIM_MAX(a, b) (a < b ? b : a)
#define | GIM_MIN(a, b) (a > b ? b : a)
#define | GIM_MAX3(a, b, c) GIM_MAX(a, GIM_MAX(b, c))
#define | GIM_MIN3(a, b, c) GIM_MIN(a, GIM_MIN(b, c))
#define | GIM_IS_ZERO(value) (value < G_EPSILON && value > -G_EPSILON)
#define | GIM_IS_NEGATIVE(value) (value <= -G_EPSILON)
#define | GIM_IS_POSISITVE(value) (value >= G_EPSILON)
#define | GIM_NEAR_EQUAL(v1, v2) GIM_IS_ZERO((v1 - v2))
#define | GIM_CLAMP(number, minval, maxval) (number < minval ? minval : (number > maxval ? maxval : number))
| returns a clamped number
#define | GIM_GREATER(x, y) btFabs(x) > (y)
#define | GIM_SWAP_NUMBERS(a, b)
| Swap numbers.
#define | GIM_INV_SQRT(va, isva)
#define | GIM_SQRT(va, sva)

## Enumerations
enum | GIM_SCALAR_TYPES { G_STYPE_REAL = 0 , G_STYPE_REAL2 , G_STYPE_SHORT , G_STYPE_USHORT , G_STYPE_INT , G_STYPE_UINT , G_STYPE_INT64 , G_STYPE_UINT64 }

## Functions
GREAL | gim_inv_sqrt (GREAL f)
| Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt.html.
GREAL | gim_sqrt (GREAL f)

## Detailed Description

Author
  Francisco Leon Najera

Definition in file gim_math.h.

## Macro Definition Documentation

## ◆ G_DEGTORAD

#define G_DEGTORAD | ( |  | X | ) | ((X)*3.1415926f / 180.0f)

Definition at line 70 of file gim_math.h.

## ◆ G_EPSILON

#define G_EPSILON SIMD_EPSILON

Definition at line 56 of file gim_math.h.

## ◆ G_HALF_PI

#define G_HALF_PI 1.5707963f

Definition at line 47 of file gim_math.h.

## ◆ G_PI

#define G_PI 3.14159265358979f

Definition at line 46 of file gim_math.h.

## ◆ G_RADTODEG

#define G_RADTODEG | ( |  | X | ) | ((X)*180.0f / 3.1415926f)

Definition at line 71 of file gim_math.h.

## ◆ G_REAL_INFINITY

#define G_REAL_INFINITY FLT_MAX

Definition at line 54 of file gim_math.h.

## ◆ G_ROOT2

#define G_ROOT2 1.41421f

Definition at line 52 of file gim_math.h.

## ◆ G_ROOT3

#define G_ROOT3 1.73205f

Definition at line 51 of file gim_math.h.

## ◆ G_SIGN_BITMASK

#define G_SIGN_BITMASK 0x80000000

Definition at line 55 of file gim_math.h.

## ◆ G_TWO_PI

#define G_TWO_PI 6.28318530f

Definition at line 49 of file gim_math.h.

## ◆ G_UINT_INFINITY

#define G_UINT_INFINITY 0xffffffff

A very very high value.

Definition at line 53 of file gim_math.h.

## ◆ GIM_AIR

#define GIM_AIR | ( |  | x | ) | (GIM_IR(x) & 0x7fffffff)

Absolute integer representation of a floating-point value.

Definition at line 80 of file gim_math.h.

## ◆ GIM_CLAMP

#define GIM_CLAMP | ( |  | number,
|  |  | minval,
|  |  | maxval
| ) |  | (number < minval ? minval : (number > maxval ? maxval : number))

returns a clamped number

Definition at line 100 of file gim_math.h.

## ◆ GIM_FR

#define GIM_FR | ( |  | x | ) | ((GREAL&)(x))

Floating-point representation of an integer value.

Definition at line 83 of file gim_math.h.

## ◆ GIM_GREATER

#define GIM_GREATER | ( |  | x,
|  |  | y
| ) |  | btFabs(x) > (y)

Definition at line 102 of file gim_math.h.

## ◆ GIM_INV_SQRT

#define GIM_INV_SQRT | ( |  | va,
|  |  | isva
| ) |  |

Value:
{ \
if (va <= 0.0000001f) \
{ \
isva = G_REAL_INFINITY; \
} \
else \
{ \
GREAL _x = va * 0.5f; \
GUINT _y = 0x5f3759df - (GIM_IR(va) >> 1); \
isva = GIM_FR(_y); \
isva = isva * (1.5f - (_x * isva * isva)); \
} \
}
GREAL
#define GREAL
Definition: gim_math.h:37
GIM_IR
#define GIM_IR(x)
Integer representation of a floating-point value.
Definition: gim_math.h:74
GUINT
#define GUINT
Definition: gim_math.h:40
G_REAL_INFINITY
#define G_REAL_INFINITY
Definition: gim_math.h:54
GIM_FR
#define GIM_FR(x)
Floating-point representation of an integer value.
Definition: gim_math.h:83

Definition at line 112 of file gim_math.h.

## ◆ GIM_IR

#define GIM_IR | ( |  | x | ) | ((GUINT&)(x))

Integer representation of a floating-point value.

Definition at line 74 of file gim_math.h.

## ◆ GIM_IS_NEGATIVE

#define GIM_IS_NEGATIVE | ( |  | value | ) | (value <= -G_EPSILON)

Definition at line 93 of file gim_math.h.

## ◆ GIM_IS_POSISITVE

#define GIM_IS_POSISITVE | ( |  | value | ) | (value >= G_EPSILON)

Definition at line 95 of file gim_math.h.

## ◆ GIM_IS_ZERO

#define GIM_IS_ZERO | ( |  | value | ) | (value < G_EPSILON && value > -G_EPSILON)

Definition at line 91 of file gim_math.h.

## ◆ GIM_MAX

#define GIM_MAX | ( |  | a,
|  |  | b
| ) |  | (a < b ? b : a)

Definition at line 85 of file gim_math.h.

## ◆ GIM_MAX3

#define GIM_MAX3 | ( |  | a,
|  |  | b,
|  |  | c
| ) |  | GIM_MAX(a, GIM_MAX(b, c))

Definition at line 88 of file gim_math.h.

## ◆ GIM_MIN

#define GIM_MIN | ( |  | a,
|  |  | b
| ) |  | (a > b ? b : a)

Definition at line 86 of file gim_math.h.

## ◆ GIM_MIN3

#define GIM_MIN3 | ( |  | a,
|  |  | b,
|  |  | c
| ) |  | GIM_MIN(a, GIM_MIN(b, c))

Definition at line 89 of file gim_math.h.

## ◆ GIM_NEAR_EQUAL

#define GIM_NEAR_EQUAL | ( |  | v1,
|  |  | v2
| ) |  | GIM_IS_ZERO((v1 - v2))

Definition at line 97 of file gim_math.h.

## ◆ GIM_SIR

#define GIM_SIR | ( |  | x | ) | ((GINT&)(x))

Signed integer representation of a floating-point value.

Definition at line 77 of file gim_math.h.

## ◆ GIM_SQRT

#define GIM_SQRT | ( |  | va,
|  |  | sva
| ) |  |

Value:
{ \
GIM_INV_SQRT(va, sva); \
sva = 1.0f / sva; \
}

Definition at line 127 of file gim_math.h.

## ◆ GIM_SWAP_NUMBERS

#define GIM_SWAP_NUMBERS | ( |  | a,
|  |  | b
| ) |  |

Value:
{ \
a = a + b; \
b = a - b; \
a = a - b; \
}

Swap numbers.

Definition at line 105 of file gim_math.h.

## ◆ GINT

#define GINT int

Definition at line 39 of file gim_math.h.

## ◆ GINT64

#define GINT64 long long

Definition at line 43 of file gim_math.h.

## ◆ GREAL

#define GREAL btScalar

Definition at line 37 of file gim_math.h.

## ◆ GREAL2

#define GREAL2 double

Definition at line 38 of file gim_math.h.

## ◆ GSHORT

#define GSHORT short

Definition at line 41 of file gim_math.h.

## ◆ GUINT

#define GUINT unsigned int

Definition at line 40 of file gim_math.h.

## ◆ GUINT64

#define GUINT64 unsigned long long

Definition at line 44 of file gim_math.h.

## ◆ GUSHORT

#define GUSHORT unsigned short

Definition at line 42 of file gim_math.h.

## Enumeration Type Documentation

## ◆ GIM_SCALAR_TYPES

enum GIM_SCALAR_TYPES

Enumerator
G_STYPE_REAL |
G_STYPE_REAL2 |
G_STYPE_SHORT |
G_STYPE_USHORT |
G_STYPE_INT |
G_STYPE_UINT |
G_STYPE_INT64 |
G_STYPE_UINT64 |

Definition at line 58 of file gim_math.h.

## Function Documentation

## ◆ gim_inv_sqrt()

GREAL gim_inv_sqrt | ( | GREAL | f | ) |
| inline

Computes 1.0f / sqrtf(x). Comes from Quake3. See http://www.magic-software.com/3DGEDInvSqrt.html.

Definition at line 134 of file gim_math.h.

## ◆ gim_sqrt()

GREAL gim_sqrt | ( | GREAL | f | ) |
| inline

Definition at line 141 of file gim_math.h.