Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis15/src/lib/include/diderot/kdtree.hxx
ViewVC logotype

Diff of /branches/vis15/src/lib/include/diderot/kdtree.hxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3915, Fri May 27 21:32:46 2016 UTC revision 3916, Sat May 28 12:01:02 2016 UTC
# Line 47  Line 47 
47        public:        public:
48    
49        protected:        protected:
50          KDNode *new_node ();          __details::KDNode *new_node ();
51          KDLeaf *new_leaf ();          __details::KDLeaf *new_leaf ();
52    
53        private:        private:
54          KDNodeBase      *_root;          __details::KDNodeBase   *_root;
55    
56          struct Chunk {          struct Chunk {
57              char        *_mem;              char        *_mem;
# Line 62  Line 62 
62          std::vector<Chunk>      _chunks;        // memory pool          std::vector<Chunk>      _chunks;        // memory pool
63      };      };
64    
65    // are two 1D positions within a specified spherical radius    // are two 1D positions within a specified spherical radius?
66      template <typename REAL>      template <typename REAL>
67      inline bool withinSphere (REAL pos1, REAL pos2, REAL radius)      inline bool withinSphere1 (REAL pos1, REAL pos2, REAL radius)
68      {      {
69          return abs(pos1 - pos2) <= radius;          return abs(pos1 - pos2) <= radius;
70      }      }
71    
72    // are two 1D positions within a specified retangular radius    // are two 1D positions within a specified retangular radius?
73      template <typename REAL>      template <typename REAL>
74      inline bool withinBox (REAL pos1, REAL pos2, REAL radius)      inline bool withinBox1 (REAL pos1, REAL pos2, REAL radius)
75      {      {
76          return abs(pos1 - pos2) <= radius;          return abs(pos1 - pos2) <= radius;
77      }      }
78    
79    // are two 2D positions within a specified spherical radius    // are two 2D positions within a specified spherical radius?
80      template <typename REAL>      template <typename REAL>
81      inline bool withinSphere (vec2<REAL> pos1, vec2<REAL> pos2, REAL radius)      inline bool withinSphere2 (vec2<REAL> pos1, vec2<REAL> pos2, REAL radius)
82      {      {
83          REAL dx = pos1[0] - pos2[0];          REAL dx = pos1[0] - pos2[0];
84          REAL dy = pos1[1] - pos2[1];          REAL dy = pos1[1] - pos2[1];
85          return (dx*dx + dy*dy) <= (radius * radius);          return (dx*dx + dy*dy) <= (radius * radius);
86      }      }
87    
88    // are two 2D positions within a specified retangular radius    // are two 2D positions within a specified retangular radius?
89      template <typename REAL>      template <typename REAL>
90      inline bool withinBox (vec2<REAL> pos1, vec2<REAL> pos2, REAL radius)      inline bool withinBox2 (vec2<REAL> pos1, vec2<REAL> pos2, REAL radius)
91      {      {
92          return withinBox(pos1[0], pos2[0], radius)          return withinBox(pos1[0], pos2[0], radius)
93              && withinBox(pos1[1], pos2[1], radius);              && withinBox(pos1[1], pos2[1], radius);
94      }      }
95    
96    // are two 3D positions within a specified spherical radius    // are two 3D positions within a specified spherical radius?
97      template <typename REAL>      template <typename REAL>
98      inline bool withinSphere (vec3<REAL> pos1, vec3<REAL> pos2, REAL radius)      inline bool withinSphere3 (vec3<REAL> pos1, vec3<REAL> pos2, REAL radius)
99      {      {
100          REAL dx = pos1[0] - pos2[0];          REAL dx = pos1[0] - pos2[0];
101          REAL dy = pos1[1] - pos2[1];          REAL dy = pos1[1] - pos2[1];
# Line 103  Line 103 
103          return (dx*dx + dy*dy + dz*dz) <= (radius * radius);          return (dx*dx + dy*dy + dz*dz) <= (radius * radius);
104      }      }
105    
106    // are two 3D positions within a specified retangular radius    // are two 3D positions within a specified retangular radius?
107      template <typename REAL>      template <typename REAL>
108      inline bool withinBox (vec3<REAL> pos1, vec3<REAL> pos2, REAL radius)      inline bool withinBox3 (vec3<REAL> pos1, vec3<REAL> pos2, REAL radius)
109      {      {
110          return withinBox(pos1[0], pos2[0], radius)          return withinBox(pos1[0], pos2[0], radius)
111              && withinBox(pos1[1], pos2[1], radius)              && withinBox(pos1[1], pos2[1], radius)

Legend:
Removed from v.3915  
changed lines
  Added in v.3916

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0