Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
RStarBoundingBox< dimensions > Struct Template Reference

#include <RStarBoundingBox.h>

Public Member Functions

void reset ()
 
bool stretch (const RStarBoundingBox< dimensions > &bb)
 
int edgeDeltas () const
 
double area () const
 
bool encloses (const RStarBoundingBox< dimensions > &bb) const
 
bool overlaps (const RStarBoundingBox< dimensions > &bb) const
 
double overlap (const RStarBoundingBox< dimensions > &bb) const
 
double distanceFromCenter (const RStarBoundingBox< dimensions > &bb) const
 
bool operator== (const RStarBoundingBox< dimensions > &bb)
 
std::string ToString () const
 

Static Public Member Functions

static RStarBoundingBox MaximumBounds ()
 

Public Attributes

std::pair< double, double > edges [dimensions]
 

Detailed Description

template<std::size_t dimensions>
struct RStarBoundingBox< dimensions >

Definition at line 30 of file RStarBoundingBox.h.

Member Function Documentation

template<std::size_t dimensions>
double RStarBoundingBox< dimensions >::area ( ) const
inline

Definition at line 89 of file RStarBoundingBox.h.

90  {
91  double area = 1;
92  for (std::size_t axis = 0; axis < dimensions; axis++)
93  area *= (double)(edges[axis].second - edges[axis].first);
94 
95  return area;
96  }
double area() const
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
double RStarBoundingBox< dimensions >::distanceFromCenter ( const RStarBoundingBox< dimensions > &  bb) const
inline

Definition at line 170 of file RStarBoundingBox.h.

171  {
172  double distance = 0, t;
173  for (std::size_t axis = 0; axis < dimensions; axis++)
174  {
175  t = ((double)edges[axis].first + (double)edges[axis].second +
176  (double)bb.edges[axis].first + (double)bb.edges[axis].second)
177  /2.0;
178  distance += t*t;
179  }
180 
181  return distance;
182  }
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
int RStarBoundingBox< dimensions >::edgeDeltas ( ) const
inline

Definition at line 79 of file RStarBoundingBox.h.

80  {
81  double distance = 0;
82  for (std::size_t axis = 0; axis < dimensions; axis++)
83  distance += edges[axis].second - edges[axis].first;
84 
85  return distance;
86  }
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
std::pair< double, double > edges[dimensions]
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
template<std::size_t dimensions>
bool RStarBoundingBox< dimensions >::encloses ( const RStarBoundingBox< dimensions > &  bb) const
inline

Definition at line 99 of file RStarBoundingBox.h.

100  {
101  // if (y1 < x1 || x2 < y2)
102  for (std::size_t axis = 0; axis < dimensions; axis++)
103  if (bb.edges[axis].first < edges[axis].first || edges[axis].second < bb.edges[axis].second)
104  return false;
105 
106  return true;
107  }
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
static RStarBoundingBox RStarBoundingBox< dimensions >::MaximumBounds ( )
inlinestatic

Definition at line 46 of file RStarBoundingBox.h.

47  {
49  bound.reset();
50  return bound;
51  }
template<std::size_t dimensions>
bool RStarBoundingBox< dimensions >::operator== ( const RStarBoundingBox< dimensions > &  bb)
inline

Definition at line 185 of file RStarBoundingBox.h.

186  {
187  for (std::size_t axis = 0; axis < dimensions; axis++)
188  if (edges[axis].first != bb.edges[axis].first || edges[axis].second != bb.edges[axis].second)
189  return false;
190 
191  return true;
192  }
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
double RStarBoundingBox< dimensions >::overlap ( const RStarBoundingBox< dimensions > &  bb) const
inline

Definition at line 124 of file RStarBoundingBox.h.

125  {
126  double area = 1.0;
127  for (std::size_t axis = 0; area && axis < dimensions; axis++)
128  {
129  // this makes it easier to understand
130  const double x1 = edges[axis].first;
131  const double x2 = edges[axis].second;
132  const double y1 = bb.edges[axis].first;
133  const double y2 = bb.edges[axis].second;
134 
135  // left edge outside left edge
136  if (x1 < y1)
137  {
138  // and right edge inside left edge
139  if (y1 < x2)
140  {
141  // right edge outside right edge
142  if (y2 < x2)
143  area *= (double)( y2 - y1 );
144  else
145  area *= (double)( x2 - y1 );
146 
147  continue;
148  }
149  }
150  // right edge inside left edge
151  else if (x1 < y2)
152  {
153  // right edge outside right edge
154  if (x2 < y2)
155  area *= (double)( x2 - x1 );
156  else
157  area *= (double)( y2 - x1 );
158 
159  continue;
160  }
161 
162  // if we get here, there is no overlap
163  return 0.0;
164  }
165 
166  return area;
167  }
double area() const
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
bool RStarBoundingBox< dimensions >::overlaps ( const RStarBoundingBox< dimensions > &  bb) const
inline

Definition at line 110 of file RStarBoundingBox.h.

111  {
112  // do it this way so theres no equal signs (in case of doubles)
113  // if (!(x1 < y2) && !(x2 > y1))
114  for (std::size_t axis = 0; axis < dimensions; axis++)
115  {
116  if (!(edges[axis].first < bb.edges[axis].second) || !(bb.edges[axis].first < edges[axis].second))
117  return false;
118  }
119 
120  return true;
121  }
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
void RStarBoundingBox< dimensions >::reset ( )
inline

Definition at line 36 of file RStarBoundingBox.h.

37  {
38  for (std::size_t axis = 0; axis < dimensions; axis++)
39  {
41  edges[axis].second = std::numeric_limits<double>::min();
42  }
43  }
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::pair< double, double > edges[dimensions]
template<std::size_t dimensions>
bool RStarBoundingBox< dimensions >::stretch ( const RStarBoundingBox< dimensions > &  bb)
inline

Definition at line 55 of file RStarBoundingBox.h.

56  {
57  bool ret = false;
58 
59  for (std::size_t axis = 0; axis < dimensions; axis++)
60  {
61 
62  if (edges[axis].first > bb.edges[axis].first)
63  {
64  edges[axis].first = bb.edges[axis].first;
65  ret = true;
66  }
67 
68  if (edges[axis].second < bb.edges[axis].second)
69  {
70  edges[axis].second = bb.edges[axis].second;
71  ret = true;
72  }
73  }
74 
75  return ret;
76  }
std::pair< double, double > edges[dimensions]
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
template<std::size_t dimensions>
std::string RStarBoundingBox< dimensions >::ToString ( ) const
inline

Definition at line 196 of file RStarBoundingBox.h.

197  {
198  std::stringstream name("");
199  name << "[";
200  for (std::size_t axis = 0; axis < dimensions; axis++)
201  {
202  name << "(" << edges[axis].first << "," << edges[axis].second << ")";
203  if (axis != dimensions -1)
204  name << ",";
205  }
206  name << "]";
207 
208  return name.str();
209  }
static QCString name
Definition: declinfo.cpp:673
std::pair< double, double > edges[dimensions]

Member Data Documentation

template<std::size_t dimensions>
std::pair<double, double> RStarBoundingBox< dimensions >::edges[dimensions]

Definition at line 33 of file RStarBoundingBox.h.


The documentation for this struct was generated from the following file: