Ignition Math

API Reference

6.9.3~pre2
AxisAlignedBox.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_AXISALIGNEDBOX_HH_
18 #define IGNITION_MATH_AXISALIGNEDBOX_HH_
19 
20 #include <iostream>
21 #include <tuple>
22 #include <ignition/math/config.hh>
23 #include <ignition/math/Helpers.hh>
24 #include <ignition/math/Line3.hh>
27 #include <ignition/math/Vector3.hh>
28 
29 namespace ignition
30 {
31  namespace math
32  {
33  // Inline bracket to help doxygen filtering.
34  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
35  //
36  // Forward declaration of private data
37  class AxisAlignedBoxPrivate;
38 
42  class IGNITION_MATH_VISIBLE AxisAlignedBox
43  {
50  public: AxisAlignedBox();
51 
56  public: AxisAlignedBox(const Vector3d &_vec1, const Vector3d &_vec2);
57 
66  public: AxisAlignedBox(double _vec1X, double _vec1Y, double _vec1Z,
67  double _vec2X, double _vec2Y, double _vec2Z);
68 
71  public: AxisAlignedBox(const AxisAlignedBox &_b);
72 
74  public: virtual ~AxisAlignedBox();
75 
78  public: double XLength() const;
79 
82  public: double YLength() const;
83 
86  public: double ZLength() const;
87 
90  public: math::Vector3d Size() const;
91 
94  public: math::Vector3d Center() const;
95 
98  public: void Merge(const AxisAlignedBox &_box);
99 
103  public: AxisAlignedBox &operator=(const AxisAlignedBox &_b);
104 
108  public: AxisAlignedBox operator+(const AxisAlignedBox &_b) const;
109 
113  public: const AxisAlignedBox &operator+=(const AxisAlignedBox &_b);
114 
118  public: bool operator==(const AxisAlignedBox &_b) const;
119 
123  public: bool operator!=(const AxisAlignedBox &_b) const;
124 
128  public: AxisAlignedBox operator-(const Vector3d &_v);
129 
133  public: AxisAlignedBox operator+(const Vector3d &_v);
134 
138  public: AxisAlignedBox operator-(const Vector3d &_v) const;
139 
143  public: AxisAlignedBox operator+(const Vector3d &_v) const;
144 
149  public: friend std::ostream &operator<<(std::ostream &_out,
151  {
152  _out << "Min[" << _b.Min() << "] Max[" << _b.Max() << "]";
153  return _out;
154  }
155 
158  public: const Vector3d &Min() const;
159 
162  public: const Vector3d &Max() const;
163 
166  public: Vector3d &Min();
167 
170  public: Vector3d &Max();
171 
178  public: bool Intersects(const AxisAlignedBox &_box) const;
179 
183  public: bool Contains(const Vector3d &_p) const;
184 
191  public: bool IntersectCheck(const Vector3d &_origin, const Vector3d &_dir,
192  const double _min, const double _max) const;
193 
209  public: std::tuple<bool, double> IntersectDist(
210  const Vector3d &_origin, const Vector3d &_dir,
211  const double _min, const double _max) const;
212 
230  public: std::tuple<bool, double, Vector3d> Intersect(
231  const Vector3d &_origin, const Vector3d &_dir,
232  const double _min, const double _max) const;
233 
242  public: std::tuple<bool, double, Vector3d> Intersect(
243  const Line3d &_line) const;
244 
247  public: double Volume() const;
248 
258  public: double IGN_DEPRECATED(6.0) DensityFromMass(
259  const double _mass) const;
260 
274  public: bool IGN_DEPRECATED(6.0) SetDensityFromMass(
275  const double _mass);
276 
280  public: const ignition::math::Material IGN_DEPRECATED(6.0)
281  &Material() const;
282 
286  public: void IGN_DEPRECATED(6.0) SetMaterial(
287  const ignition::math::Material &_mat);
288 
297  public: bool IGN_DEPRECATED(6.0) MassMatrix(
298  MassMatrix3d &_massMat) const;
299 
306  private: bool ClipLine(const int _d, const Line3d &_line,
307  double &_low, double &_high) const;
308 
310  private: AxisAlignedBoxPrivate *dataPtr;
311  };
312  }
313  }
314 }
315 #endif
friend std::ostream & operator<<(std::ostream &_out, const AxisAlignedBox &_b)
Output operator.
Definition: AxisAlignedBox.hh:149
const Vector3d & Max() const
Get the maximum corner.
A class for inertial information about a rigid body consisting of the scalar mass and a 3x3 symmetric...
Definition: MassMatrix3.hh:45
Contains information about a single material.
Definition: Material.hh:65
The Vector3 class represents the generic vector containing 3 elements. Since it&#39;s commonly used to ke...
Definition: Vector3.hh:41
A three dimensional line segment. The line is defined by a start and end point.
Definition: Line3.hh:35
Definition: Angle.hh:42
const Vector3d & Min() const
Get the minimum corner.
STL class.
Mathematical representation of a box that is aligned along an X,Y,Z axis.
Definition: AxisAlignedBox.hh:42