Box.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
26 namespace ignition
27 {
28  namespace math
29  {
30  // Forward declaration of private data
31  class BoxPrivate;
32 
36  {
38  public: Box();
39 
44  public: Box(const Vector3d &_vec1, const Vector3d &_vec2);
45 
54  public: Box(double _vec1X, double _vec1Y, double _vec1Z,
55  double _vec2X, double _vec2Y, double _vec2Z);
56 
59  public: Box(const Box &_b);
60 
62  public: virtual ~Box();
63 
66  public: double XLength() const;
67 
70  public: double YLength() const;
71 
74  public: double ZLength() const;
75 
78  public: math::Vector3d Size() const;
79 
82  public: math::Vector3d Center() const;
83 
86  public: void Merge(const Box &_box);
87 
91  public: Box &operator=(const Box &_b);
92 
96  public: Box operator+(const Box &_b) const;
97 
101  public: const Box &operator+=(const Box &_b);
102 
106  public: bool operator==(const Box &_b) const;
107 
111  public: bool operator!=(const Box &_b) const;
112 
116  public: Box operator-(const Vector3d &_v);
117 
122  public: friend std::ostream &operator<<(std::ostream &_out,
123  const ignition::math::Box &_b)
124  {
125  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
126  return _out;
127  }
128 
131  public: const Vector3d &Min() const;
132 
135  public: const Vector3d &Max() const;
136 
139  public: Vector3d &Min();
140 
143  public: Vector3d &Max();
144 
150  public: bool Intersects(const Box &_box) const;
151 
155  public: bool Contains(const Vector3d &_p) const;
156 
163  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
164  const double _min, const double _max) const;
165 
181  public: std::tuple<bool, double> IntersectDist(
182  const Vector3d &_origin, const Vector3d &_dir,
183  const double _min, const double _max) const;
184 
202  public: std::tuple<bool, double, Vector3d> Intersect(
203  const Vector3d &_origin, const Vector3d &_dir,
204  const double _min, const double _max) const;
205 
214  public: std::tuple<bool, double, Vector3d> Intersect(
215  const Line3d &_line) const;
216 
223  private: bool ClipLine(const int _d, const Line3d &_line,
224  double &_low, double &_high) const;
225 
227  private: BoxPrivate *dataPtr;
228  };
229  }
230 }
231 #endif
const Vector3d & Max() const
Get the maximum corner.
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:201
Mathematical representation of a box and related functions.
Definition: Box.hh:35
friend std::ostream & operator<<(std::ostream &_out, const ignition::math::Box &_b)
Output operator.
Definition: Box.hh:122
const Vector3d & Min() const
Get the minimum corner.
Definition: BoxPrivate.hh:28
A three dimensional line segment.
Definition: Line3.hh:32
Definition: AffineException.hh:30