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.

Defines

#define M_PI   3.14159265358979323846
 Pi.
#define M_2PI   (2.0*M_PI)
 2*Pi.
#define SWAP(a, b, c)   {c=a;a=b;b=c;}
 Swaps two values.
#define PI2PI(a)   {while(a>M_PI) a-=M_2PI; while (a<-M_PI) a+=M_2PI;}
 Forces an angle go be in [-pi,pi].
#define NEW(_var, _n, _type)
 Allocates memory space.
#define MEM_EXPAND(_var, _n, _type)
 Expands a previously allocated memory space.
#define MEM_DUP(_var, _n, _type)   {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
 Duplicates a previously allocated memory space.
#define NO_UINT   ((unsigned int)(-1))
#define INF   1e200
 Infinite.
#define TRUE   1
 TRUE.
#define FALSE   0
 FALSE.
#define TOPOLOGY_R   1
 One of the possible topologies.
#define TOPOLOGY_S   2
 One of the possible topologies.

Typedefs

typedef unsigned int boolean
 Boolean type.

Detailed Description

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

Definition in file definitions.h.


Define Documentation

#define M_PI   3.14159265358979323846

An approximation of Pi

Definition at line 24 of file definitions.h.

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

#define M_2PI   (2.0*M_PI)

Two times Pi.

Definition at line 32 of file definitions.h.

Referenced by SquaredDistanceToRectangle(), and SquaredDistanceToRectangleDimension().

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

Swaps two values using an intermediate storage.

Parameters:
a First value to swap.
b Second value to swap.
c Intermediate storage for the swap.

Definition at line 49 of file definitions.h.

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

#define PI2PI (  )     {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:
a The variable to set within the [-pi,pi] range.

Definition at line 64 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 76 of file definitions.h.

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

#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 88 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 101 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 111 of file definitions.h.

Referenced by BuildKDTree(), and NearestNeighbour().

#define INF   1e200

Infinite (a large possitive number).

Definition at line 119 of file definitions.h.

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

#define TRUE   1

TRUE

Definition at line 139 of file definitions.h.

Referenced by BuildKDTree(), and main().

#define FALSE   0

FALSE

Definition at line 148 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 158 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 166 of file definitions.h.

Referenced by main(), and VectorSquaredDistanceTopologyMin().


Typedef Documentation

typedef unsigned int boolean

Type with two possible values: TRUE,FALSE.

Definition at line 130 of file definitions.h.