The Cuik KD-Tree Library


definitions.h File Reference

Definition of constants and macros used in several parts of the library. More...

#include <stdlib.h>
#include <math.h>
+ Include dependency graph for definitions.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 Pi. More...
 
#define M_2PI   (2.0*M_PI)
 2*Pi. More...
 
#define ANGLE_ACCURACY   1e-4
 Accuracy used to compare angles. More...
 
#define SWAP(a, b, c)   {c=a;a=b;b=c;}
 Swaps two values. More...
 
#define PI2PI(a)   { if ((a<-M_PI)||(a>M_PI)) { while(a>M_PI) a-=M_2PI; while (a<-M_PI) a+=M_2PI; }}
 Forces an angle go be in [-pi,pi]. More...
 
#define NEW(_var, _n, _type)
 Allocates memory space. More...
 
#define NEWZ(_var, _n, _type)
 Allocates memory space and initializes to zero. More...
 
#define MEM_EXPAND(_var, _n, _type)
 Expands a previously allocated memory space. More...
 
#define MEM_DUP(_var, _n, _type)   {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
 Duplicates a previously allocated memory space. More...
 
#define NO_UINT   ((unsigned int)(-1))
 Used to denote an identifier that has not been initialized. More...
 
#define INF   1e200
 Infinite. More...
 
#define TRUE   1
 TRUE. More...
 
#define FALSE   0
 FALSE. More...
 
#define TOPOLOGY_R   1
 One of the possible topologies. More...
 
#define TOPOLOGY_S   2
 One of the possible topologies. More...
 

Typedefs

typedef unsigned int boolean
 Boolean type. More...
 

Detailed Description

Definition of constants and macros used in several parts of the cuik-kdtree library.

Definition in file definitions.h.

Macro Definition Documentation

#define M_PI   3.14159265358979323846
#define M_2PI   (2.0*M_PI)

Two times Pi.

Definition at line 32 of file definitions.h.

Referenced by SquaredDistanceToRectangle(), and SquaredDistanceToRectangleDimension().

#define ANGLE_ACCURACY   1e-4

Two angular values are the same if they are closer than this value.

Definition at line 44 of file definitions.h.

Referenced by InitKDTree(), SquaredDistanceToRectangle(), and SquaredDistanceToRectangleDimension().

#define SWAP (   a,
  b,
 
)    {c=a;a=b;b=c;}

Swaps two values using an intermediate storage.

Parameters
aFirst value to swap.
bSecond value to swap.
cIntermediate storage for the swap.

Definition at line 60 of file definitions.h.

Referenced by BuildKDTree().

#define PI2PI (   a)    { if ((a<-M_PI)||(a>M_PI)) { while(a>M_PI) a-=M_2PI; while (a<-M_PI) a+=M_2PI; }}

Forces an angle go be in [-pi,pi]. This is intended to be used with a variable as a parameter (using an expression would be ineficient).

Parameters
aThe variable to set within the [-pi,pi] range.

Definition at line 75 of file definitions.h.

Referenced by SquaredDistanceToRectangle(), SquaredDistanceToRectangleDimension(), and VectorSquaredDistanceTopologyMin().

#define NEW (   _var,
  _n,
  _type 
)
Value:
{(_var)=(_type *)malloc(sizeof(_type)*(_n)); \
if (!(_var)) exit(EXIT_FAILURE);}

Allocates memory space for _n elements of type _type and assigns the pointer to _var. If the memory can not be allocated, stops the execution.

Definition at line 87 of file definitions.h.

Referenced by AddPoint2KDtree(), BuildKDTree(), CopyRectangle(), InitRectangleFromPoint(), main(), and NeighboursInBall().

#define NEWZ (   _var,
  _n,
  _type 
)
Value:
{(_var)=(_type *)calloc(_n,sizeof(_type)); \
if (!(_var)) exit(EXIT_FAILURE);}

Allocates memory space for _n elements of type _type and assigns the pointer to _var. If the memory can not be allocated, stops the execution. The allocated memory is set to 0.

Definition at line 98 of file definitions.h.

Referenced by InitRectangle().

#define MEM_EXPAND (   _var,
  _n,
  _type 
)
Value:
{(_var)=(_type *)realloc((void *)(_var),sizeof(_type)*(_n)); \
if (!(_var)) exit(EXIT_FAILURE);}

Expands a previously reserved memory space so that it can accomodate _n elements of type _type assigns the pointer to _var. The previously allocated space is pointed by _var. If the memory can not be expanded, stops the execution.

Definition at line 110 of file definitions.h.

#define MEM_DUP (   _var,
  _n,
  _type 
)    {(_n)*=2;MEM_EXPAND(_var,_n,_type);}

Dublicates a previously reserved memory space that accomodates _n elements of type _type. After the duplication, the pointer _var takes to a memory space that can accomodate 2*_n elements and the value of variable _n is also doubled.

Definition at line 123 of file definitions.h.

Referenced by main(), and SearchInBallKDtree().

#define NO_UINT   ((unsigned int)(-1))

Used to denote an identifier that has not been initialized.

Definition at line 133 of file definitions.h.

Referenced by BuildKDTree(), and NearestNeighbour().

#define INF   1e200

Infinite (a large possitive number).

Definition at line 141 of file definitions.h.

Referenced by AddPoint2KDtree(), BuildKDTree(), main(), and NearestNeighbour().

#define TRUE   1

TRUE

Definition at line 161 of file definitions.h.

Referenced by BuildKDTree(), and main().

#define FALSE   0

FALSE

Definition at line 170 of file definitions.h.

Referenced by BuildKDTree(), and main().

#define TOPOLOGY_R   1

The range of the variables is defined over the reals.

Definition at line 180 of file definitions.h.

Referenced by main(), SquaredDistanceToRectangle(), and SquaredDistanceToRectangleDimension().

#define TOPOLOGY_S   2

The range of the variables is defined over a circle.

Definition at line 188 of file definitions.h.

Referenced by InitKDTree(), main(), and VectorSquaredDistanceTopologyMin().

Typedef Documentation

typedef unsigned int boolean

Type with two possible values: TRUE,FALSE.

Definition at line 152 of file definitions.h.