Ignition Math

API Reference

4.0.0
Box.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_MATH_BOX_HH_
18 #define IGNITION_MATH_BOX_HH_
19 
20 #include <iostream>
21 #include <tuple>
22 #include <ignition/math/Helpers.hh>
23 #include <ignition/math/Vector3.hh>
24 #include <ignition/math/Line3.hh>
25 #include <ignition/math/config.hh>
26 
27 namespace ignition
28 {
29  namespace math
30  {
31  // Inline bracket to help doxygen filtering.
32  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
33  //
34  // Forward declaration of private data
35  class BoxPrivate;
36 
39  class IGNITION_MATH_VISIBLE Box
40  {
47  public: Box();
48 
53  public: Box(const Vector3d &_vec1, const Vector3d &_vec2);
54 
63  public: Box(double _vec1X, double _vec1Y, double _vec1Z,
64  double _vec2X, double _vec2Y, double _vec2Z);
65 
68  public: Box(const Box &_b);
69 
71  public: virtual ~Box();
72 
75  public: double XLength() const;
76 
79  public: double YLength() const;
80 
83  public: double ZLength() const;
84 
87  public: math::Vector3d Size() const;
88 
91  public: math::Vector3d Center() const;
92 
95  public: void Merge(const Box &_box);
96 
100  public: Box &operator=(const Box &_b);
101 
105  public: Box operator+(const Box &_b) const;
106 
110  public: const Box &operator+=(const Box &_b);
111 
115  public: bool operator==(const Box &_b) const;
116 
120  public: bool operator!=(const Box &_b) const;
121 
125  public: Box operator-(const Vector3d &_v);
126 
131  public: friend std::ostream &operator<<(std::ostream &_out,
132  const ignition::math::Box &_b)
133  {
134  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
135  return _out;
136  }
137 
140  public: const Vector3d &Min() const;
141 
144  public: const Vector3d &Max() const;
145 
148  public: Vector3d &Min();
149 
152  public: Vector3d &Max();
153 
159  public: bool Intersects(const Box &_box) const;
160 
164  public: bool Contains(const Vector3d &_p) const;
165 
172  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
173  const double _min, const double _max) const;
174 
190  public: std::tuple<bool, double> IntersectDist(
191  const Vector3d &_origin, const Vector3d &_dir,
192  const double _min, const double _max) const;
193 
211  public: std::tuple<bool, double, Vector3d> Intersect(
212  const Vector3d &_origin, const Vector3d &_dir,
213  const double _min, const double _max) const;
214 
223  public: std::tuple<bool, double, Vector3d> Intersect(
224  const Line3d &_line) const;
225 
232  private: bool ClipLine(const int _d, const Line3d &_line,
233  double &_low, double &_high) const;
234 
236  private: BoxPrivate *dataPtr;
237  };
238  }
239  }
240 }
241 #endif
const Vector3d & Min() const
Get the minimum corner.
const Vector3d & Max() const
Get the maximum corner.
Mathematical representation of a box and related functions.
Definition: Box.hh:39
friend std::ostream & operator<<(std::ostream &_out, const Box &_b)
Output operator.
Definition: Box.hh:131
The Vector3 class represents the generic vector containing 3 elements. Since it&#39;s commonly used to ke...
Definition: Vector3.hh:40
A three dimensional line segment. The line is defined by a start and end point.
Definition: Line3.hh:35
Definition: Angle.hh:39
STL class.