Permalink
Browse files

Removed requirement of function kdtree_distance()

  • Loading branch information...
pranjal-rai committed Aug 17, 2017
1 parent 44f0b54 commit b83c291bd49115d8813dae4ac2f77fdab6ef2d6e
@@ -48,15 +48,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -50,15 +50,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -99,17 +99,6 @@ struct KDTreeVectorOfVectorsAdaptor
return m_data.size();
}
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline num_t kdtree_distance(const num_t *p1, const size_t idx_p2,size_t size) const
{
num_t s=0;
for (size_t i=0; i<size; i++) {
const num_t d= p1[i]-m_data[idx_p2][i];
s+=d*d;
}
return s;
}
// Returns the dim'th component of the idx'th point in the class:
inline num_t kdtree_get_pt(const size_t idx, int dim) const {
return m_data[idx][dim];
@@ -51,15 +51,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -48,15 +48,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline float kdtree_distance(const float *p1, const size_t idx_p2,size_t size) const
{
float d0=p1[0]-pts[idx_p2].x;
float d1=p1[1]-pts[idx_p2].y;
float d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -68,15 +68,6 @@ struct PointCloudAdaptor
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return derived().pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline coord_t kdtree_distance(const coord_t *p1, const size_t idx_p2,size_t /*size*/) const
{
const coord_t d0=p1[0]-derived().pts[idx_p2].x;
const coord_t d1=p1[1]-derived().pts[idx_p2].y;
const coord_t d2=p1[2]-derived().pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -51,15 +51,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -49,15 +49,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -51,15 +51,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /*size */) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
View
@@ -368,7 +368,12 @@ namespace nanoflann
L2_Simple_Adaptor(const DataSource &_data_source) : data_source(_data_source) { }
inline DistanceType operator()(const T* a, const size_t b_idx, size_t size) const {
return data_source.kdtree_distance(a,b_idx,size);
DistanceType result = DistanceType();
for (int i=0; i<size; ++i) {
const DistanceType diff = a[i] - data_source.kdtree_get_pt(b_idx, i);
result += diff * diff;
}
return result;
}
template <typename U, typename V>
@@ -389,6 +394,7 @@ namespace nanoflann
InnerProdQuat_Adaptor(const DataSource &_data_source) : data_source(_data_source) { }
inline DistanceType operator()(const T* a, const size_t b_idx, size_t size) const {
// Update this
return data_source.kdtree_distance(a,b_idx,size);
}
@@ -410,6 +416,7 @@ namespace nanoflann
acosInnerProdQuat_Adaptor(const DataSource &_data_source) : data_source(_data_source) { }
inline DistanceType operator()(const T* a, const size_t b_idx, size_t size) const {
// Update this
return data_source.kdtree_distance(a,b_idx,size);
}
@@ -1018,8 +1025,6 @@ namespace nanoflann
* // Must return the number of data poins
* inline size_t kdtree_get_point_count() const { ... }
*
* // [Only if using the metric_L2_Simple type] Must return the Euclidean (L2) distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
* inline DistanceType kdtree_distance(const T *p1, const size_t idx_p2,size_t size) const { ... }
*
* // Must return the dim'th component of the idx'th point in the class:
* inline T kdtree_get_pt(const size_t idx, int dim) const { ... }
@@ -1396,9 +1401,6 @@ namespace nanoflann
* // Must return the number of data poins
* inline size_t kdtree_get_point_count() const { ... }
*
* // [Only if using the metric_L2_Simple type] Must return the Euclidean (L2) distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
* inline DistanceType kdtree_distance(const T *p1, const size_t idx_p2,size_t size) const { ... }
*
* // Must return the dim'th component of the idx'th point in the class:
* inline T kdtree_get_pt(const size_t idx, int dim) const { ... }
*
@@ -66,15 +66,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t size) const
{
T d0=p1[0]-pts[idx_p2].x;
T d1=p1[1]-pts[idx_p2].y;
T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
@@ -63,15 +63,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline float kdtree_distance(const float *p1, const size_t idx_p2,size_t size) const
{
float d0=p1[0]-pts[idx_p2].x;
float d1=p1[1]-pts[idx_p2].y;
float d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.
View
@@ -61,15 +61,6 @@ struct PointCloud
// Must return the number of data points
inline size_t kdtree_get_point_count() const { return pts.size(); }
// Returns the distance between the vector "p1[0:size-1]" and the data point with index "idx_p2" stored in the class:
inline T kdtree_distance(const T *p1, const size_t idx_p2,size_t /* size*/) const
{
const T d0=p1[0]-pts[idx_p2].x;
const T d1=p1[1]-pts[idx_p2].y;
const T d2=p1[2]-pts[idx_p2].z;
return d0*d0+d1*d1+d2*d2;
}
// Returns the dim'th component of the idx'th point in the class:
// Since this is inlined and the "dim" argument is typically an immediate value, the
// "if/else's" are actually solved at compile time.

0 comments on commit b83c291

Please sign in to comment.