## [r36646]: trunk / contrib / brl / bbas / vsph / vsph_sph_box_2d.h  Maximize  Restore  History

### 168 lines (135 with data), 6.3 kB

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167``` ```#ifndef vsph_sph_box_2d_h_ #define vsph_sph_box_2d_h_ //: // \file // \brief An axis-aligned box on the unit sphere. // \author J.L. Mundy // \date February 1, 2013 // \verbatim // Modifications none // \endverbatim #include #include #include #include #include //: // theta is elevation, phi is azimuth // // Note that the creation of intervals on the azimuth circle is not // well-defined. In contrast to intervals on the real line, // there is an ambiguity as to which portion of the circle is // the bounded set of angles. That is two points divide the circle // into two arcs and the bounded set could be either one. Thus it is // necessary to have three points. Points a and b define the two arcs and // point c determines which arc contains the bounded set. // // To infer the bounded set from a sequence of points it is necessary to assume // the initial three points are "compact," that is that they all lie in the // smaller of the two arcs. That is |b - a|<180 and a >& verts, vcl_vector >& quads, double tol = 0.01) const; //: display the box as a set of planar quadrilaterals in vrml void display_box(vcl_ostream& os, float r, float g, float b, double tol = 0.01, double factor =1.0) const; //: display a set of boxes static void display_boxes(vcl_string const& path, vcl_vector const& boxes, vcl_vector > colors, double tol = 0.01, double factor =1.0); //: support for binary I/O void print(vcl_ostream& os, bool in_radians = true) const; void b_read(vsl_b_istream& is); void b_write(vsl_b_ostream& os); short version() const {return 1;} private: //: the value of pi in the units of *this box double pye() const; //: reduce phi to the range +-180 (assumed in *this angle units) double reduce_phi(double phi) const; //: bounds of ccw traversal of phi interval in *this angle units void phi_bounds(double& phi_start, double& phi_end) const; //: update the current theta bounds void update_theta(double th); //: the azimuth angle ph is outside the current interval so extend it bool extend_interval(double ph); //: the angle units of *this box bool in_radians_; //: the three azimuth angles that define an unambigous bounded set // a and b define two circular intervals and c determines the bounded interval double a_phi_, b_phi_, c_phi_; //: the bounds on elevation double min_th_, max_th_; }; //: return a box that represents the intersection of two boxes (could be empty) // note that it is possible to have two disjoint intervals in phi (2 boxes) bool intersection(vsph_sph_box_2d const& b1, vsph_sph_box_2d const& b2, vcl_vector& boxes); vcl_ostream& operator<<(vcl_ostream& os, vsph_sph_box_2d const& p); #endif //vsph_sph_box_2d_h_ ```

No, thanks