The Cuik KD-Tree Library


rectangle.h
Go to the documentation of this file.
1 #ifndef RECTANGLEH
2 #define RECTANGLEH
3 
4 #include "definitions.h"
5 
6 #include <stdio.h>
7 
8 
26 typedef struct {
27  unsigned int n;
28  double *l;
29  double *u;
30 } Trectangle;
31 
42 void InitRectangle(unsigned int dim,double *l,double *u,Trectangle *b);
43 
53 void InitRectangleFromPoint(unsigned int dim,double *p,Trectangle *b);
54 
64 unsigned int GetRectangleDim(Trectangle *b);
65 
76 void ExpandRectangle(double *p,Trectangle *b);
77 
91 double EnlargeRectangleWithLimits(double r,Trectangle *limits,
92  Trectangle *bIn,Trectangle *bOut);
93 
103 void CopyRectangle(Trectangle *b_out,Trectangle *b_in);
104 
115 inline double GetRectangleLowerLimit(unsigned int i,Trectangle *b);
116 
127 inline double GetRectangleUpperLimit(unsigned int i,Trectangle *b);
128 
139 inline void GetRectangleLimits(unsigned int i,double *l,double *u,Trectangle *b);
140 
150 inline void SetRectangleLowerLimit(unsigned int i,double l,Trectangle *b);
151 
161 inline void SetRectangleUpperLimit(unsigned int i,double u,Trectangle *b);
162 
173 inline void SetRectangleLimits(unsigned int i,double l,double u,Trectangle *b);
174 
184 void RandomPointInRectangle(double *c,Trectangle *b);
185 
199 double SquaredDistanceToRectangleDimension(unsigned int dim,double p,unsigned int *tp,Trectangle *b);
200 
217 double SquaredDistanceToRectangle(double t2,double *p,unsigned int *tp,Trectangle *b);
218 
231 unsigned int GetRectangleSplitDim(Trectangle *b);
232 
241 void PrintRectangle(FILE *f,Trectangle *b);
242 
251 void DeleteRectangle(Trectangle *b);
252 
253 #endif
void RandomPointInRectangle(double *c, Trectangle *b)
Returns the a random point along the selected dimensions.
Definition: rectangle.c:145
unsigned int GetRectangleSplitDim(Trectangle *b)
Computes the rectangle dimension for which it is better to split the rectangle.
Definition: rectangle.c:344
void GetRectangleLimits(unsigned int i, double *l, double *u, Trectangle *b)
Gets the limits of the rectangle along a given dimension.
Definition: rectangle.c:115
double GetRectangleLowerLimit(unsigned int i, Trectangle *b)
Get the lower limit.
Definition: rectangle.c:101
double SquaredDistanceToRectangleDimension(unsigned int dim, double p, unsigned int *tp, Trectangle *b)
Squared distance from a value to a given rectangle dimension.
Definition: rectangle.c:153
double * u
Definition: rectangle.h:29
void InitRectangleFromPoint(unsigned int dim, double *p, Trectangle *b)
Initializes a rectangle from a point.
Definition: rectangle.c:35
void SetRectangleLowerLimit(unsigned int i, double l, Trectangle *b)
Set the lower limit.
Definition: rectangle.c:123
void CopyRectangle(Trectangle *b_out, Trectangle *b_in)
Rectangle copy operator.
Definition: rectangle.c:91
double SquaredDistanceToRectangle(double t2, double *p, unsigned int *tp, Trectangle *b)
Squared distance from a point to a rectangle.
Definition: rectangle.c:230
void ExpandRectangle(double *p, Trectangle *b)
Expands a rectangle so that it includes a given point.
Definition: rectangle.c:52
void DeleteRectangle(Trectangle *b)
Destructor.
Definition: rectangle.c:375
double GetRectangleUpperLimit(unsigned int i, Trectangle *b)
Get the upper limit.
Definition: rectangle.c:108
Definition of constants and macros used in several parts of the library.
void SetRectangleUpperLimit(unsigned int i, double u, Trectangle *b)
Set the upper limit.
Definition: rectangle.c:130
A rectangle.
Definition: rectangle.h:26
void InitRectangle(unsigned int dim, double *l, double *u, Trectangle *b)
Initializes a rectangle.
Definition: rectangle.c:20
void PrintRectangle(FILE *f, Trectangle *b)
Prints a rectangle.
Definition: rectangle.c:365
double * l
Definition: rectangle.h:28
unsigned int GetRectangleDim(Trectangle *b)
Returns the dimension of the rectangle.
Definition: rectangle.c:47
unsigned int n
Definition: rectangle.h:27
void SetRectangleLimits(unsigned int i, double l, double u, Trectangle *b)
Changes a rectangle along a given dimension.
Definition: rectangle.c:137
double EnlargeRectangleWithLimits(double r, Trectangle *limits, Trectangle *bIn, Trectangle *bOut)
Enlarges a box remaining in a given limits.
Definition: rectangle.c:68