BRL-CAD
fixpt.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fixpt
 

Macros

#define LIBRT_PRIMITIVES_FIXPT_H   seen
 
#define FIXPT_SCALE   ((1<<28)-1)
 
#define FIXPT_FLOAT(fp, fl)
 
#define FLOAT_FIXPT(fp)   (fp.i + ((double)fp.f)/FIXPT_SCALE)
 
#define FIXPT_NORMALIZE(fp)
 
#define FIXPT_ROUND(fp)
 
#define FIXPT_ADD2(o, a, b)
 
#define PR_FIX(str, fp)   bu_log("%s = %2d+x%8.8x\n", str, fp.i, fp.f)
 
#define PR_FIX2(str, fp)
 

Detailed Description

Data structures and macros for dealing with integer-based fixed point math.

These macros use integer instructions for a special "fixed point" format. The fractional part is stored in 28-bit integer form, to prevent roundoff errors.

Definition in file fixpt.h.

Macro Definition Documentation

#define LIBRT_PRIMITIVES_FIXPT_H   seen

Definition at line 35 of file fixpt.h.

#define FIXPT_SCALE   ((1<<28)-1)

Definition at line 37 of file fixpt.h.

#define FIXPT_FLOAT (   fp,
  fl 
)
Value:
{ \
register double d = fl; \
fp.f = (d - (fp.i = (int)d)) * FIXPT_SCALE; \
#define FIXPT_SCALE
Definition: fixpt.h:37
#define FIXPT_NORMALIZE(fp)
Definition: fixpt.h:51

Definition at line 44 of file fixpt.h.

#define FLOAT_FIXPT (   fp)    (fp.i + ((double)fp.f)/FIXPT_SCALE)

Definition at line 49 of file fixpt.h.

#define FIXPT_NORMALIZE (   fp)
Value:
{ \
if (fp.f < 0) { \
do { \
fp.i--; \
fp.f += FIXPT_SCALE; \
} while (fp.f < 0); \
} else if (fp.f >= FIXPT_SCALE) { \
do { \
fp.i++; \
fp.f -= FIXPT_SCALE; \
} while (fp.f >= FIXPT_SCALE); \
} }
#define FIXPT_SCALE
Definition: fixpt.h:37
if(share_geom)
Definition: nmg_mod.c:3829

Definition at line 51 of file fixpt.h.

#define FIXPT_ROUND (   fp)
Value:
{ \
if (fp.f > FIXPT_SCALE/2) { \
if (fp.i >= 0) fp.i++; \
else fp.i--; \
} fp.f = 0; }
#define FIXPT_SCALE
Definition: fixpt.h:37
if(share_geom)
Definition: nmg_mod.c:3829
else
Definition: nmg_mod.c:3872

Definition at line 64 of file fixpt.h.

#define FIXPT_ADD2 (   o,
  a,
 
)
Value:
{\
o.i = a.i + b.i; \
o.f = a.f + b.f; \
#define FIXPT_NORMALIZE(fp)
Definition: fixpt.h:51

Definition at line 70 of file fixpt.h.

#define PR_FIX (   str,
  fp 
)    bu_log("%s = %2d+x%8.8x\n", str, fp.i, fp.f)

Definition at line 75 of file fixpt.h.

#define PR_FIX2 (   str,
  fp 
)
Value:
bu_log("%s = (%2d+x%8.8x, %2d+x%8.8x)\n", \
str, fp[0].i, fp[0].f, fp[1].i, fp[1].f)
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176

Definition at line 77 of file fixpt.h.